Can I define an interface with a channel in Go? I would like to define an interface that would allow me to use objects of different types that would all have the same channel defined. EXE:
type I interface {
chan Communications []byte
otherMethod()
}
(This give syntax error: unexpected token chan. I tried a few different syntaxes and some googling with no avail.)
An interface does not hold data, it defines what something implements.
You could have a method that returns a channel. eg:
type I interface {
getChannel() (chan []byte)
otherMethod()
}
Please read up on interfaces. The tour would help.