go
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGo
Go
- Propagate the existing request context through downstream work.
- Use only at process bootstrap or intentionally detached workers.
context.Background() - Prefer explicit code and constructor injection.
- Avoid package-level mutable state.
- Wrap errors with useful context. Never silently ignore them.
- Match existing project patterns before adding helpers.
- Add tests for new behaviour.
- Avoid dependencies unless the standard library or installed packages fall short.
Completion: changed Go code preserves request context, has explicit dependencies and useful errors, follows local package patterns, and passes the narrowest relevant tests.
- 在下游工作中传递现有的请求 context。
- 仅在进程启动阶段或有意脱离请求上下文的工作任务中使用 。
context.Background() - 优先使用显式依赖和构造函数注入。
- 避免使用包级可变状态。
- 使用有用的上下文包装错误。切勿静默忽略错误。
- 添加辅助函数之前,先遵循现有项目的模式。
- 为新行为添加测试。
- 除非标准库或已安装的包无法满足需求,否则避免引入依赖项。
完成标准:修改后的 Go 代码能够保留请求 context,具备显式依赖和有意义的错误处理,遵循本地包模式,并通过范围最窄的相关测试。