Skip to content

Linter to check whether you have variable name collision with imported packages.

Notifications You must be signed in to change notification settings

hrvadl/pkgcollision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pkgcollision

pkgcollision is a program to check whether you have variable name collision with the packages you imported.

Install

go install github.com/hrvadl/pkgcollision/cmd/pkgcollision

Usage

To scan all packages run:

pkgcollision ./...

To scan specific packages run:

pkgcollision pkgName

Example

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()

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

TODO

  • Add ignore comments
  • Add ignore path options
  • Enhace README.md
  • Add tests
  • More meaningfull error message

About

Linter to check whether you have variable name collision with imported packages.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages