44package lintertest
55
66import (
7+ "context"
78 "flag"
89 "fmt"
910 "log"
@@ -28,14 +29,16 @@ func stringComparison() {
2829
2930func returnString () string { return "foo" }
3031
31- //
3232// One space.
33- // Two spaces.
34- // One tab.
35- // Two tabs.
36- //No space. // want "Use either //<one-or-more-spaces>comment or //<one-or-more-tabs>comment format for comments"
33+ //
34+ // Two spaces.
35+ // One tab.
36+ // Two tabs.
37+ //
38+ // No space. // want "Use either //<one-or-more-spaces>comment or //<one-or-more-tabs>comment format for comments"
39+ //
3740// Tab and spaces. // want "Use either //<one-or-more-spaces>comment or //<one-or-more-tabs>comment format for comments"
38- // Space and tab. // want "Use either //<one-or-more-spaces>comment or //<one-or-more-tabs>comment format for comments"
41+ // Space and tab. // want "Use either //<one-or-more-spaces>comment or //<one-or-more-tabs>comment format for comments"
3942func checkCommentSpace () {
4043 checkCommentSpace () // lower-case comment is OK
4144 // Capital letter comment.
@@ -126,13 +129,13 @@ func varDecls() {
126129
127130func minmax () {
128131 x , y := 0 , 0
129- if x < y + 1 { // want "Use max function instead"
132+ if x < y + 1 { // want "Use max function instead"
130133 x = y + 1
131134 }
132- if x >= y { // want "Use max function instead"
135+ if x >= y { // want "Use max function instead"
133136 y = x
134137 }
135- if x > 10 { // want "Use min function instead"
138+ if x > 10 { // want "Use min function instead"
136139 x = 10
137140 }
138141}
@@ -145,10 +148,31 @@ func loopvar() {
145148 }
146149}
147150
148- func anyInterface () interface {} { // want "Use any instead of interface{}"
149- var v interface {} // want "Use any instead of interface{}"
150- func (interface {}) {} (v ) // want "Use any instead of interface{}"
151+ func anyInterface () interface {} { // want "Use any instead of interface{}"
152+ var v interface {} // want "Use any instead of interface{}"
153+ func (interface {}) {}(v ) // want "Use any instead of interface{}"
151154 var y any
152- func (any ) {} (y )
155+ func (any ) {}(y )
153156 return v
154157}
158+
159+ func contextArgs (ctx context.Context ) {
160+ }
161+
162+ func contextArgsBad1 (c context.Context ) { // want "Context variable must be named 'ctx'"
163+ }
164+
165+ func contextArgsBad2 (a int , ctx context.Context ) { // want "Context must be the first argument"
166+ }
167+
168+ func contextArgsBad4 (ctx context.Context , a int ) {
169+ }
170+
171+ func TestContextArgsGood (t * testing.T , ctx context.Context ) {
172+ }
173+
174+ func TestContextArgsBad1 (t * testing.T , c context.Context ) { // want "Context variable must be named 'ctx'"
175+ }
176+
177+ func TestContextArgsBad2 (t * testing.T , a int , ctx context.Context ) { // want "Context must be the first argument"
178+ }
0 commit comments