github.com/code-reading/golang@v0.0.0-20220303082512-ba5bc0e589a3/coding/runtime/00-chan.go (about)

     1  package main
     2  
     3  import "fmt"
     4  
     5  func main() {
     6  	c := make(chan int)
     7  	go func() {
     8  		c <- 1 // send to channel
     9  	}()
    10  
    11  	x := <-c       // recv from channel
    12  	fmt.Println(x) // 1
    13  }