pkgcollision is a program to check whether you have variable name collision with the packages you imported.
go install github.com/hrvadl/pkgcollision/cmd/pkgcollision
To scan all packages run:
pkgcollision ./...
To scan specific packages run:
pkgcollision pkgName
Let's say you have following code:
package main
import (
"fmt"
"github.com/hrvadl/pkgcollision/internal/app"
)
func main() {
app := app.New()
fmt.Println(app)
}
pkgcollision
will produce the following output:
/Users/vadym.hrashchenko/go/pkgcollision/cmd/pkgcollision/main.go:10:2: found collision with package 'app': app := app.New()
It forbids to name variables with the same name as imported packages. Package name collision can be annoying and can even lead to unexpected errors, therefore it'd be better to avoid it.
- Add ignore comments
- Add ignore path options
- Enhace README.md
- Add tests
- More meaningfull error message