From 49b0fb03849fcfed4c30395cb7da84491de40a58 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 19 Dec 2025 12:42:34 +0100 Subject: tools/syz-linter: suggest any instead of interface{} Any is the preferred over interface{} now in Go. --- tools/syz-linter/linter.go | 8 ++++++++ tools/syz-linter/testdata/src/lintertest/lintertest.go | 8 ++++++++ 2 files changed, 16 insertions(+) (limited to 'tools') diff --git a/tools/syz-linter/linter.go b/tools/syz-linter/linter.go index 5b3d2210d..97e8f2963 100644 --- a/tools/syz-linter/linter.go +++ b/tools/syz-linter/linter.go @@ -77,6 +77,8 @@ func run(p *analysis.Pass) (any, error) { pass.checkIfStmt(n) case *ast.AssignStmt: pass.checkAssignStmt(n) + case *ast.InterfaceType: + pass.checkInterfaceType(n) } return true }) @@ -406,3 +408,9 @@ func (pass *Pass) checkAssignStmt(n *ast.AssignStmt) { } pass.report(n, "Don't duplicate loop variables. They are per-iter (not per-loop) since go122.") } + +func (pass *Pass) checkInterfaceType(n *ast.InterfaceType) { + if len(n.Methods.List) == 0 { + pass.report(n, "Use any instead of interface{}") + } +} diff --git a/tools/syz-linter/testdata/src/lintertest/lintertest.go b/tools/syz-linter/testdata/src/lintertest/lintertest.go index 4a3a48656..60b59c0ae 100644 --- a/tools/syz-linter/testdata/src/lintertest/lintertest.go +++ b/tools/syz-linter/testdata/src/lintertest/lintertest.go @@ -144,3 +144,11 @@ func loopvar() { _, _ = i, v } } + +func anyInterface() interface{} { // want "Use any instead of interface{}" + var v interface{} // want "Use any instead of interface{}" + func(interface{}) {} (v) // want "Use any instead of interface{}" + var y any + func(any) {} (y) + return v +} -- cgit mrf-deployment