add channel sample2
1 parent c76eb88 commit cec73fc3cd5d1c7c0e9158f1701099693cbf88ce
yhornisse authored on 9 Oct 2021
Showing 1 changed file
View
20
goroutine/channel2.go 0 → 100644
package main
 
import (
"fmt"
"time"
)
 
func main() {
done := make(chan int64)
go func() {
for i := 0; i < 5; i++ {
fmt.Println(i)
time.Sleep(1 * time.Second)
}
done <- 10 // send
}()
x := <- done // receicve
fmt.Println(x) // 10
}