返回资讯中心
外部精选
软件工程
#开发者实时流

Go Conventions That Clicked Too Late for an AI Engineer

10 Go Conventions That Clicked Too Late for an AI Engineer

Hacker News 最新cheikhdev2026/10/20 · 26 天前3 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Programming

10 Go Conventions That Clicked Too Late for an AI Engineer

The ones that only make sense after you’ve been burned by them

Cheikh seck

8 min read·

2 days ago

--

I spent three years writing Go for inference gateways before I realized I was fighting the language instead of using it.

I’d write a handler, ship it, and six months later someone would point out that I’d used context wrong, or that my error wrapping was leaking, or that my goroutine was going to take down the pod. Each time I'd think: why didn't anyone tell me this in week one?

These aren’t rules you learn in a tutorial. They’re conventions that only click when you’ve been burned by their absence. Here are the ten that hit me hardest.

  1. context Is Not a Request Bag — It's a Cancellation Contract

Everyone’s first instinct is to stuff values into context.WithValue. I did this for two years. Then a timeout propagated through my gateway and took down a model swap because the value was still there.

The convention that clicked: context is for cancellation, deadlines, and tracing — not for passing data your handler needs.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →