8 Star 47 Fork 21

Lucky / go-hutool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
23-channels.go 569 Bytes
一键复制 编辑 原始数据 按行查看 历史
package main
import "fmt"
func main() {
//使用 make(chan val-type) 创建一个新的通道。 通道类型就是他们需要传递值的类型。
messages := make(chan string)
//使用 channel <- 语法 发送(send) 一个新的值到通道中。这里 我们在一个新的 Go 协程中发送 "ping" 到上面创建的 messages 通道中。
go func() { messages <- "ping" }()
//使用 <-channel 语法从通道中 接收(receives) 一个值。这里 将接收我们在上面发送的 "ping" 消息并打印出来。
msg := <-messages
fmt.Println(msg)
}
Go
1
https://gitee.com/huangbosbos/go-hutool.git
git@gitee.com:huangbosbos/go-hutool.git
huangbosbos
go-hutool
go-hutool
81f09a275c3b

搜索帮助

53164aa7 5694891 3bd8fe86 5694891