我正在尝试在结构中使用 slice chan 类型,类似于下面的代码。但是,当我尝试在
test := <-c.slice
程序挂起。有没有办法做到这一点?
package main
import "fmt"
type blah struct {
slice chan [][]int
}
func main() {
slice := make([][]int, 3)
c := blah{make(chan [][]int)}
slice[0] = []int{1, 2, 3}
slice[1] = []int{4, 5, 6}
slice[2] = []int{7, 8, 9}
go func() {
test := <- c.slice
test = slice
c.slice <- test
}()
fmt.Println(<-c.slice)
}