ctxstruct

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ctxstruct 检查 struct 字段是否持有 context.Context。

Go 官方明确的反模式:ctx 只应作为函数首参在调用链上传递, 存进 struct 会把请求生命周期和对象生命周期搅在一起 (appkit 的 ctx 防火墙、事务传播都依赖 ctx 只走参数这一前提)。

默认只查生产代码(_test.go 不查),-tests=true 连测试一起查。

Index

Constants

This section is empty.

Variables

View Source
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL