https://github.com/hrvadl/pkgcollision
Linter to check whether you have variable name collision with imported packages.
https://github.com/hrvadl/pkgcollision
collision collision-detection go golang linter package variable
Last synced: 10 months ago
JSON representation
Linter to check whether you have variable name collision with imported packages.
- Host: GitHub
- URL: https://github.com/hrvadl/pkgcollision
- Owner: hrvadl
- Created: 2024-09-16T06:53:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-16T07:28:09.000Z (over 1 year ago)
- Last Synced: 2025-01-30T12:24:40.528Z (12 months ago)
- Topics: collision, collision-detection, go, golang, linter, package, variable
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pkgcollision
pkgcollision is a program to check whether you have variable name collision with the packages you imported.
## Install
```sh
go install github.com/hrvadl/pkgcollision/cmd/pkgcollision
```
## Usage
To scan all packages run:
```sh
pkgcollision ./...
```
To scan specific packages run:
```sh
pkgcollision pkgName
```
## Example
Let's say you have following code:
```go
package main
import (
"fmt"
"github.com/hrvadl/pkgcollision/internal/app"
)
func main() {
app := app.New()
fmt.Println(app)
}
```
`pkgcollision` will produce the following output:
```sh
/Users/vadym.hrashchenko/go/pkgcollision/cmd/pkgcollision/main.go:10:2: found collision with package 'app': app := app.New()
```
## Rules
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.
## Inspired by
- [100 Go mistakes and how to avoid them](https://www.manning.com/books/100-go-mistakes-and-how-to-avoid-them)
## TODO
- Add ignore comments
- Add ignore path options
- Enhace README.md
- Add tests
- More meaningfull error message