Golang 缓冲 channel : Ignore/suppress sending repeated values

标签 go channel buffered

关闭。这个问题需要details or clarity .它目前不接受答案。












想改进这个问题?通过 editing this post 添加详细信息并澄清问题.

1年前关闭。




Improve this question




在 golang 中从一个 goroutine 我将消息发布到缓冲 channel 。但是我的 reader goroutine 的处理速度可能有点慢,并且从 channel 中读取的任何内容都可能不会更快。
因此,为了阻止 channel 缓冲区被填满,我不希望在缓冲 channel 中再次发布相同的数据。有没有办法做到这一点?

最佳答案

Is there a way to do that?



不。

channel (缓冲或不缓冲)是不透明的,除了从它们发送或接收之外,您什么也做不了,它们绝对不提供进一步的逻辑。

关于Golang 缓冲 channel : Ignore/suppress sending repeated values,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62190538/

相关文章:

python - 在通过 open() 获得的流上使用 io.BufferedReader?

java - 程序在 bufferedreader 关闭时卡住

go - 是否有可能知道 Go 中函数的返回值类型?

go - 如何在 DataStore 中存储 *time.Time 类型的结构字段的当前时间?

multithreading - 如果一个 goroutine 已完成,控制 goroutine 关闭的规范方法是什么?

自动信道检测算法

java - BufferedReader 循环中出现错误

go - 有没有办法忽略 Golang 中的错误返回值?

使用共享代码为两个应用程序组织文件

concurrency - 数据未通过 channel 发送