Skip to content

Linter `globalcall` detects that specific functions are called in a package scope.

License

Notifications You must be signed in to change notification settings

qawatake/globalcall

Repository files navigation

globalcall

Go Reference test

Linter globalcall detects that specific functions are called in a package scope.

var i = Int() // ng because Int must not be called in a package scope.

func main() {
  j := Int() // ok
  fmt.Println(j)
}

How to use

Build your globalcall binary by writing main.go like below.

package main

import (
  "github.com/qawatake/globalcall"
  "golang.org/x/tools/go/analysis/unitchecker"
)

func main() {
  unitchecker.Main(
    globalcall.NewAnalyzer(
      globalcall.Func{
        PkgPath:  "pkg/in/which/target/func/is/defined",
        FuncName: "Call",
      },
    ),
  )
}

Then, run go vet with your globalcall binary.

go vet -vettool=/path/to/your/globalcall ./...

About

Linter `globalcall` detects that specific functions are called in a package scope.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published