Table of Contents

Channel

What is it?

A channel is a typed conduit for sending and receiving values between goroutines. It helps coordinate and synchronize concurrent work.

What is it used for?

Example

package main
 
import "fmt"
 
func main() {
    ch := make(chan int)
 
    go func() {
        ch <- 10 // send
    }()
 
    v := <-ch // receive
    fmt.Println(v)
}

Hard words (English)