// The close built-in function closes a channel, which must be either
// bidirectional or send-only. It should be executed only by the sender,
// never the receiver, and has the effect of shutting down the channel after
// the last sent value is received. After the last value has been received
// from a closed channel c, any receive from c will succeed without
// blocking, returning the zero value for the channel element. The form
// x, ok := <-c
// will also set ok to false for a closed channel.
func close(c chan<- Type)
共 4 个回复
stevewang
B关闭channel,A收到关闭消息后结束当前任务。
xinyu391
当然是最后接触chan的 负责关闭了啊
nzai
B负责关闭chan,关闭后A依然可以从chan中读出剩余未读数据,并且A可以判读chan是否关闭了
JY115
Go内置函数
close()
官方文档介绍