/ArgOverwritten

A go analyzer that finds function arguments being overwritten

Primary LanguageGoMIT LicenseMIT

ArgOverwritten

made-with-Go made-with-Go MIT license PRs Welcome

ArgOverwritten finds function arguments being overwritten. Check out my blog post on writing the analyzer!

Quick Start:

Download the package

go get github.com/amit-davidson/ArgOverwritten/cmd/argoverwritten

Pass the entry point

go vet -vettool=$(which argoverwritten) ${path_to_file}

Example:

package testdata

func body(a int) {
	_ = func() {
		a = 5
	}
}

func main() {
	body(5)
}
go vet -vettool=$(which argoverwritten) /testdata/OverwritingParamFromOuterScope

Output

/testdata/OverwritingParamFromOuterScope/main.go:5:3: "a" overwrites func parameter