File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,8 @@ func run(p *analysis.Pass) (any, error) {
7777 pass .checkIfStmt (n )
7878 case * ast.AssignStmt :
7979 pass .checkAssignStmt (n )
80+ case * ast.InterfaceType :
81+ pass .checkInterfaceType (n )
8082 }
8183 return true
8284 })
@@ -406,3 +408,9 @@ func (pass *Pass) checkAssignStmt(n *ast.AssignStmt) {
406408 }
407409 pass .report (n , "Don't duplicate loop variables. They are per-iter (not per-loop) since go122." )
408410}
411+
412+ func (pass * Pass ) checkInterfaceType (n * ast.InterfaceType ) {
413+ if len (n .Methods .List ) == 0 {
414+ pass .report (n , "Use any instead of interface{}" )
415+ }
416+ }
Original file line number Diff line number Diff line change @@ -144,3 +144,11 @@ func loopvar() {
144144 _ , _ = i , v
145145 }
146146}
147+
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+ var y any
152+ func (any ) {} (y )
153+ return v
154+ }
You can’t perform that action at this time.
0 commit comments