package main
import (
"time"
"fmt"
)
func main() {
c := make(chan string)
go func() {
time.Sleep(1 * time.Second)
c <- "hello from chan" // 数据发送到channel中
}()
msg := <- c // 阻塞知道受到数据
fmt.Print(msg)
}
原文:https://www.cnblogs.com/php-linux/p/13055628.html