Senior
What is the `<-ch` construct in Go?
sobes.tech AI
Answer from AI
The <-ch construction in Go is used to receive a value from the channel ch. It is a channel read operation that blocks until a value appears in the channel.
Example:
ch := make(chan int)
go func() {
ch <- 42 // send a value into the channel
}()
value := <-ch // read a value from the channel, blocks until the value is available
fmt.Println(value) // will output 42
Thus, <-ch is syntax for receiving data from a channel, ensuring synchronization between goroutines.