File tree 5 files changed +42
-0
lines changed
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