Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 golang 中从一个 goroutine 我将消息发布到缓冲通道。但是我的 reader goroutine 的处理速度可能有点慢,并且从通道中读取的任何内容都可能不会更快。因此,为了阻止通道缓冲区被填满,我不希望在缓冲通道中再次发布相同的数据。有没有办法做到这一点?
有没有办法做到这一点?
不。
通道(缓冲或不缓冲)是不透明的,除了从它们发送或接收之外,您什么也做不了,它们绝对不提供进一步的逻辑。