Junior — Middle
Milline väärtus antakse edasi teise parameetrina funktsioonile make, kui luuakse kanal Go-s?
sobes.tech AI
Vastus AI-lt
In Go, the make function is used to create slices, maps, and channels. When creating a channel, the second parameter indicates the buffer capacity of the channel.
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.
Therefore, the second parameter is the size of the channel's buffer.