Check that no globals are present in Go code.
Clone or download
leonklingele and leighmcculloch Fix line number for variables inside var group (#9)
In groups of variables that share a single 'var' token the app
is outputting the line number of the 'var' token, which is the
same for each variable in the group. It's better to output the
line number of the actual variable.
Latest commit abbdf6e Jan 18, 2019

README.md

gochecknoglobals

Build Status Codecov Go Report Card

Check that no globals are present in Go code.

Why

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.

https://peter.bourgon.org/blog/2017/06/09/theory-of-modern-go.html https://twitter.com/davecheney/status/871939730761547776

Install

go get 4d63.com/gochecknoglobals

Usage

gochecknoglobals
gochecknoglobals ./...
gochecknoglobals [path] [path] [path] [etc]

Add -t to include tests.

gochecknoglobals -t [path]

Note: Paths are only inspected recursively if the Go /... recursive path suffix is appended to the path.