unuseparam
finds a unused parameter but its name is not _
.
package a
func _() {} // OK
func _(_ int) {} // OK
func _(_, _ int) {} // OK
func _(_, _ int, _ string) {} // OK
func _(n int) { _ = n } // OK
func _(_, n int) { _ = n } // OK
func _(n int) {} // want "n is unused parameter"
func _(n, m int) {} // want "n is unused parameter" "m is unused parameter"
You can get unuseparam
by go install
command (Go 1.16 and higher).
$ go install github.com/gostaticanalysis/unuseparam/cmd/unuseparam@latest
unuseparam
run with go vet
as below when Go is 1.12 and higher.
$ go vet -vettool=$(which unuseparam) ./...
You can use unuseparam.Analyzer with unitchecker.
fixunuseparam
command check and fix unused parameter to _
.
$ go install github.com/gostaticanalysis/unuseparam/cmd/fixunuseparam@latest
$ fixunuseparam ./...