Operator and syntax
Go channel send and receive
A send is a statement; receive is an expression. Receive may provide a second boolean indicating whether the value was sent before closure. A send on a closed channel panics. Example output: '7 true 0 false'.
Formal Syntax & Structure
go syntaxgo
ch <- value; <-chWorking Example
Example Snippetgo
package main
import ( "fmt")
func main() { ch := make(chan int, 1) ch <- 7 close(ch) a, ok := <-ch b, ok2 := <-ch fmt.Println(a, ok, b, ok2)}