问题:
Is it OK to leave a Go channel open forever (never close the channel) if I never check for its state?如果我从不检查其状态,是否可以让 Go 通道永远打开(永远不要关闭通道)? Will it lead to memory leaks?会导致内存泄漏吗? Is the following code OK?下面的代码好吗?
func (requestCh chan<- Request) GetResponse(data RequestData) Response {
reply := make(chan Response)
requestCh <- Request{data: data, replyCh: reply}
return <-reply
}
解决方案:
参考一: https://en.stackoom.com/question/a3bB参考二: https://stackoom.com/question/a3bB