No, go does not have generics. chan int is not the same type as chan string for instance and you cannot declare a type that hold all types of channel unless you resort to "interface {}" AND runtime reflection.
Le jeudi 22 mars 2018 16:25:39 UTC-10, 刘焱 a écrit : > > I'm trying to define a Reference Counted Channel struct, like below: > > type RefCountedChannel { > Channel chan Type > RefCount int > mux sync.Mutex > } > > I have to define different struts to hold different channel types. > But I don't care the type of Channel, I just close is when RefCount become > 0. > May I use a single Channel to hold all types of channels? > -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.