The problem is that embedding allows you to mostly use built-in type methods (as indicated in the Attachment instead of inheritance in Go ")
And channel , such as map , is an unnamed type (specified using a type literal that represents a new type from existing types.).
It does not have its own or exported fields, so you donβt go very far by introducing the channel type within struct {} .
You probably have an error message similar to the example :
func (x chan int) m2() {} invalid receiver type chan int (chan int is an unnamed type)
If the channel type is embedded in the struct type, this unnamed type will act as a receiver for the methods , which, apparently, is not allowed by the language in the first place.
source share