1 Star 1 Fork 2

masx200/the-way-to-go_ZH_CN

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
goroutine2.go 422 Bytes
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"fmt"
"time"
)
func main() {
ch := make(chan string)
go sendData(ch)
go getData(ch)
time.Sleep(1e9)
}
func sendData(ch chan string) {
ch <- "Washington"
ch <- "Tripoli"
ch <- "London"
ch <- "Beijing"
ch <- "Tokio"
}
func getData(ch chan string) {
var input string
// time.Sleep(1e9)
for {
input = <-ch
fmt.Printf("%s ", input)
}
}
// Washington Tripoli London Beijing Tokio
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/masx200/the-way-to-go_ZH_CN.git
git@gitee.com:masx200/the-way-to-go_ZH_CN.git
masx200
the-way-to-go_ZH_CN
the-way-to-go_ZH_CN
master

搜索帮助