Terry Cheng
@terrychengtw
Taipei · UTC+8
主題Theme
語言Lang
按 D 切換主題 · L 切換語言press D for theme · L for language
← 回首頁 ← Back to index
2026·03·20 深入 Deep dive 12 min · go

Go 並發的三種姿勢:goroutine、channel 與 context

大部分 Go 並發的 bug 都是「用錯姿勢」,不是工具本身有問題。這篇整理我看過的三種最常見模式。

深入文章——撰寫中。

Go 的並發好用在於工具少;它的坑也在於工具少——每一個工具都可以拿來亂用。

姿勢一:fire-and-forget goroutine

go doThing()

最短但最危險——沒有 lifecycle,panic 直接炸整個 process。

一次寫一點 慢慢累積 one thought at a time slowly