github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2012/goforc/communication1.go (about) 1 // +build OMIT 2 3 package main 4 5 import ( 6 "fmt" 7 "time" 8 ) 9 10 // START1 OMIT 11 func main() { 12 c := make(chan string) 13 go f("three", 300*time.Millisecond, c) 14 for i := 0; i < 10; i++ { 15 fmt.Println("Received", <-c) // Receive expression is just a value. // HL 16 } 17 fmt.Println("Done.") 18 } 19 20 // STOP1 OMIT 21 22 // START2 OMIT 23 func f(msg string, delay time.Duration, c chan string) { 24 for i := 0; ; i++ { 25 c <- fmt.Sprintf("%s %d", msg, i) // Any suitable value can be sent. // HL 26 time.Sleep(delay) 27 } 28 } 29 30 // STOP2 OMIT