Junior — Middle
What value is passed as the second parameter to the make function when creating a channel in Go?
sobes.tech AI
Answer from AI
In Go, the make function is used to create slices, maps, and channels. When creating a channel, the second parameter specifies the buffering of the channel — its capacity.
Example:
ch := make(chan int, 5) // creates an int channel with a buffer of 5 elements
If the second parameter is 0 or omitted, a non-buffered channel is created, where sending blocks until someone reads a value from the channel.
Thus, the second parameter is the size of the channel buffer.