Skip to content
Switch branches/tags
Go to file

Latest commit

Use analysis.Analyzer.

This will make is simpler to embed the check into golangci-lint and other similar use cases. It also simplifies the code and the testing logic which is a huge bonus.

Thanks Simon Sawert (@bombsimon) for making this change clean, and nutting out issues with running the tests.

Co-authored-by: Simon Sawert <>
Co-authored-by: Leigh McCulloch <>

Git stats


Failed to load latest commit information.


Build Status Codecov Go Report Card

Check that no globals are present in Go code.


Global variables are an input to functions that is not visible in the functions signature, complicate testing, reduces readability and increase the complexity of code.


There are very few exceptions to the global variable rule. This tool will ignore the following patterns:

  • Variables with an Err prefix
  • Variables named _
  • Variables named version
  • Variables assigned from regexp.MustCompile()


go get


The linter is built on Go's analysis package and does thus support all the built in flags and features from this type. The analyzer is executed by specifying packages.

gochecknoglobals [package]
gochecknoglobals ./...

By default, test files will not be checked but can be included by adding the -t flag.

gochecknoglobals -t [package]