Documentation
¶
Overview ¶
Package ctxstruct 检查 struct 字段是否持有 context.Context。
Go 官方明确的反模式:ctx 只应作为函数首参在调用链上传递, 存进 struct 会把请求生命周期和对象生命周期搅在一起 (appkit 的 ctx 防火墙、事务传播都依赖 ctx 只走参数这一前提)。
默认只查生产代码(_test.go 不查),-tests=true 连测试一起查。
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Analyzer = &analysis.Analyzer{
Name: "ctxstruct",
Doc: "禁止 struct 字段类型为 context.Context;ctx 只能作为函数参数传递",
Run: run,
}
Analyzer 是 ctxstruct 检查器。
Functions ¶
This section is empty.
Types ¶
This section is empty.