gpt4 book ai didi

go - 不能将 type chan []string) 用作 type []chan string?

转载 作者:IT王子 更新时间:2023-10-29 02:08:02 24 4
gpt4 key购买 nike

package main

import "fmt"

func x(foo []string, cz chan string) {
for i := range foo {
cz <- foo[i]
}
}

func y(foo []string, cz chan string) {
for i := range foo {
cz <- foo[i]
}
}

type cz struct {
cSlice []chan string
}

func main() {

var quality []string = make([]string, 2)
quality[0] = "hello"
quality[1] = "world"
//name := []string{"mother", "earth"}

var channel cz

for i := range channel.cSlice {
go x(quality, channel.cSlice[i])
go y(quality, channel.cSlice[i])
x, y := <-channel.cSlice[i], <-channel.cSlice[i]
fmt.Println(x, y)
}
}

现在什么都没有收到嗯...

更新^

...需要更多文字。

...然后再多一点。好的,还有多少?

我真的不敢相信。 fdsaf asf asfasdfdasfadfd

最佳答案

cannot use channel.cSlice (type chan []string) as type []chan string in argument to x
cannot use channel.cSlice (type chan []string) as type []chan string in argument to y

阅读错误信息。

输入chan []string

输入 []chan 字符串

它们是不同的。

Playground :https://play.golang.org/p/CKhj8DUGTle

关于go - 不能将 type chan []string) 用作 type []chan string?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54048930/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com