a := make(chan struct{})
Such this, go channel take empty struct as input. Can this input be anything?
thanks.
a := make(chan struct{})
Such this, go channel take empty struct as input. Can this input be anything?
thanks.
No: it can be an empty struct (struct{}{}
), not "anything"
To be "anything", you would need interface{}
.
As I explain in "Go Golang : anonymous struct and empty struct", an empty struct is useful to pass an object of size... 0! It is a good way to signal the completion that something has happened.