Working with Channels

Channels in Go provide a way for goroutines to communicate safely.

  • Use make(chan type) to create a channel.
  • <- is the channel operator for sending and receiving data.
  • Unbuffered vs. buffered channels for different use cases.
ch := make(chan int)

// Send
ch <- 10

// Receive
value := <-ch
← PrevNext →