'chan interface {}' dosen't work.
package main
import "fmt"
type ChannelWrapper struct {
Channel chan interface{}
}
func main() {
x := make(chan int)
y := ChannelWrapper { x }
fmt.Println(y)
}
Build this will yield
cannot use x (type chan int) as type chan interface {} in field value
Cast x as follow:
chan interface{} (x)
Will yield
cannot convert x (type chan int) to type chan interface {}
在 2018年3月24日星期六 UTC+8上午1:41:59,[email protected]写道:
>
> An empty interface var can hold any type, so you could have a chan
> interface{} then use an interface type assertion when you read a value.
>
> Matt
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.