unuseparam

package module
v0.0.0-...-c348048 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2021 License: MIT Imports: 6 Imported by: 0

README

unuseparam

pkg.go.dev

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"

Install

You can get unuseparam by go install command (Go 1.16 and higher).

$ go install github.com/gostaticanalysis/unuseparam/cmd/unuseparam@latest

How to use

unuseparam run with go vet as below when Go is 1.12 and higher.

$ go vet -vettool=$(which unuseparam) ./...

Analyze with golang.org/x/tools/go/analysis

You can use unuseparam.Analyzer with unitchecker.

Fix unused parameters

fixunuseparam command check and fix unused parameter to _.

$ go install github.com/gostaticanalysis/unuseparam/cmd/fixunuseparam@latest
$ fixunuseparam ./...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "unuseparam",
	Doc:  doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL