Channels and select / Closing channels / Essential

Run Settings
LanguageGo
Language Version
Run Command
package main import ( "fmt" "time" ) func main() { ch := make(chan string) go func() { for s := range ch { fmt.Printf("received from channel: %s\n", s) } fmt.Print("range loop finished because ch was closed\n") }() ch <- "foo" close(ch) // only to simplify example, don't sleep to coordinate // goroutines in real code time.Sleep(100 * time.Millisecond) }
Editor Settings
Theme
Key bindings
Full width
Lines