Go问答技术文章
-
Go 的 internal 包不是用来显得项目高级,而是给仓库内部代码加编译期边界。判断重点看复用范围、依赖方向、测试替身和未来演进成本。127 收藏 -
Golang · Go问答 | 3天前 | goroutine · HTTP · Context · 超时控制 · Go问答 · WithTimeout Go问答 context取消 QueryContext HTTP请求取消 goroutine退出
Go HTTP 请求断开后,r.Context() 会收到取消信号,但服务端慢任务不会凭空停止。只有把 context 继续传给数据库、下游 HTTP 调用、消息消费和 goroutine,取消与超时才会真正变成资源释放动作。120 收藏 -
Golang · Go问答 | 5天前 | 并发安全 · RWMutex · sync.Map · Go问答 · map并发 · RWMutex sync.Map Go问答 Go map并发读写 concurrent map writes
Go map 不是并发安全容器,多个 goroutine 同时写或读写交错时可能触发 fatal error。本文从线上 panic 现场出发,说明如何复现、定位原因,并在 RWMutex、sync.Map 和单 owner 模型之间做选择。102 收藏