Gochannels, creating channel with make keyword or directly?

If the data type of channels looks like “chan Type” then what are the differences between

c := make(chan string)

And

var c chan string

Which one should I use and why?

Using := declares and initialize the variable.
If you use var, you need to initialize the var using make. For example
var c chan string
c = make(chan string)`

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.