File tree Expand file tree Collapse file tree 5 files changed +42
-0
lines changed Expand file tree Collapse file tree 5 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ require (
73
73
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c
74
74
github.com/shirou/gopsutil/v3 v3.21.12
75
75
github.com/sirupsen/logrus v1.8.1
76
+ github.com/sivchari/containedctx v1.0.1
76
77
github.com/sivchari/tenv v1.4.7
77
78
github.com/sonatard/noctx v0.0.1
78
79
github.com/sourcegraph/go-diff v0.6.1
Original file line number Diff line number Diff line change
1
+ package golinters
2
+
3
+ import (
4
+ "github.com/sivchari/containedctx"
5
+ "golang.org/x/tools/go/analysis"
6
+
7
+ "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
8
+ )
9
+
10
+ func NewContainedCtx () * goanalysis.Linter {
11
+ a := containedctx .Analyzer
12
+
13
+ return goanalysis .NewLinter (
14
+ a .Name ,
15
+ a .Doc ,
16
+ []* analysis.Analyzer {a },
17
+ nil ,
18
+ ).WithLoadMode (goanalysis .LoadModeSyntax )
19
+ }
Original file line number Diff line number Diff line change @@ -183,6 +183,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
183
183
WithPresets (linter .PresetPerformance , linter .PresetBugs ).
184
184
WithURL ("https://github.com/timakin/bodyclose" ),
185
185
186
+ linter .NewConfig (golinters .NewContainedCtx ()).
187
+ WithSince ("1.44.0" ).
188
+ WithPresets (linter .PresetStyle ).
189
+ WithURL ("https://github.com/sivchari/containedctx" ),
190
+
186
191
linter .NewConfig (golinters .NewContextCheck ()).
187
192
WithSince ("v1.43.0" ).
188
193
WithPresets (linter .PresetBugs ).
Original file line number Diff line number Diff line change
1
+ // args: -Econtainedctx
2
+ package testdata
3
+
4
+ import "context"
5
+
6
+ type ok struct {
7
+ i int
8
+ s string
9
+ }
10
+
11
+ type ng struct {
12
+ ctx context.Context // ERROR "found a struct that contains a context.Context field"
13
+ }
14
+
15
+ type empty struct {}
You can’t perform that action at this time.
0 commit comments