惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 热门话题
C
Check Point Blog
Hugging Face - Blog
Hugging Face - Blog
N
News | PayPal Newsroom
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Troy Hunt's Blog
H
Heimdal Security Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Secure Thoughts
博客园 - Franky
A
Arctic Wolf
Spread Privacy
Spread Privacy
P
Proofpoint News Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
The Last Watchdog
The Last Watchdog
博客园_首页
Forbes - Security
Forbes - Security
Google DeepMind News
Google DeepMind News
Project Zero
Project Zero
T
Threatpost
Y
Y Combinator Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
小众软件
小众软件
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
博客园 - 叶小钗
量子位
Security Latest
Security Latest
酷 壳 – CoolShell
酷 壳 – CoolShell
U
Unit 42
A
About on SuperTechFans
大猫的无限游戏
大猫的无限游戏
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 聂微东
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
P
Privacy International News Feed
Help Net Security
Help Net Security
博客园 - 司徒正美
D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
C
CERT Recently Published Vulnerability Notes
T
The Exploit Database - CXSecurity.com

浩瀚星河 - 个人技术博客

工作中如何做好技术积累 wrk压测工具 千万级 Mysql 表结构变更实战 MySql主从复制 Go遍历时删除特定元素 Golang中的优雅关闭与退出 Github CI自动发版 git-filter-repo 清理敏感信息 初识mcp server 短视频的推荐算法 webhook是什么 GitLab Runner 使用与 CICD 全面指南 Go Zap实现日志双写和切割 canal安装与使用 kafka-go使用 go-elasticsearch使用指南 elasticsearch安装与使用 kratos中proto文件引入其他proto爆红 go中的defer 腾讯云发送短信 什么是勇敢 go中的方法提升 docker部署mysql中文乱码问题 10万行报表导出优化实战:从 OFFSET 到游标分页 不急于求成,才是最长远的成长 redis在go中的实践 go 反射 go timer定时器 go context学习之旅 go jwt和redis实现用户登录注册以及查询 go中的panic和recover channel实现简易eventbus channel的select case控制语句 channel之生产者消费者模型 缓冲区为 1 和无缓冲区的 channel 有什么区别 使用minio的go sdk上传文件 wire优雅的管理go项目
channel 基本概念
浩瀚星河 · 2025-08-04 · via 浩瀚星河 - 个人技术博客

在 Go 语言中,channel 是一种用于**协程间通信**的数据结构。根据是否带缓冲区,channel 可分为**无缓冲区**和**有缓冲区**两类。 **无缓冲区的 channel** 是一种同步通信方式,发送和接收必须“当场配对”,发送方在没有接收方的情况下会被挂起,直到数据被接收。这就像一个共享的杯子,只有顾客喝掉牛奶,奶农才能继续挤下一杯。 **有缓冲区的 channel** 则支持异步通信,可以预先存入一定数量的值,只在缓冲区满时才会阻塞发送。它更像一个小型车间,奶农可以提前挤奶放进去,顾客随时取用。 理解这两者的差异对于编写高效的并发程序非常关键,尤其是在处理 goroutine 调度与通信时。