func closechan(c *hchan) {
// 关闭一个 nil channel,panic
panic(plainError("close of nil channel"))
panic(plainError("close of closed channel"))
// 将 channel 所有等待接收队列的里 sudog 释放
// 如果 elem 不为空,说明此 receiver 未忽略接收数据
typedmemclr(c.elemtype, sg.elem)
sg.releasetime = cputicks()
raceacquireg(gp, unsafe.Pointer(c))
// 将 channel 等待发送队列里的 sudog 释放
// 如果存在,这些 goroutine 将会 panic
sg.releasetime = cputicks()
raceacquireg(gp, unsafe.Pointer(c))
// Ready all Gs now that we've dropped the channel lock.
glist = glist.schedlink.ptr()