File tree 5 files changed +47
-0
lines changed
5 files changed +47
-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.0
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
+ analyzers := []* analysis.Analyzer {
14
+ a ,
15
+ }
16
+
17
+ return goanalysis .NewLinter (
18
+ a .Name ,
19
+ a .Doc ,
20
+ analyzers ,
21
+ nil ,
22
+ ).WithLoadMode (goanalysis .LoadModeSyntax )
23
+ }
Original file line number Diff line number Diff line change @@ -179,6 +179,12 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
179
179
WithPresets (linter .PresetPerformance , linter .PresetBugs ).
180
180
WithURL ("https://github.com/timakin/bodyclose" ),
181
181
182
+ linter .NewConfig (golinters .NewContainedCtx ()).
183
+ WithSince ("1.44.0" ).
184
+ WithPresets (linter .PresetStyle ).
185
+ WithLoadForGoAnalysis ().
186
+ WithURL ("https://github.com/sivchari/containedctx" ),
187
+
182
188
linter .NewConfig (golinters .NewContextCheck ()).
183
189
WithSince ("v1.43.0" ).
184
190
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