globalcall

package module
v0.0.0-...-dbef86d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 10 Imported by: 0

README

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 ./...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAnalyzer

func NewAnalyzer(funcs ...Func) *analysis.Analyzer

Types

type Func

type Func struct {
	// Package path of the function or method.
	PkgPath string
	// Name of the function or method.
	FuncName string
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL