gochecknoglobals

command module
v0.0.0-...-7c3491d Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2019 License: MIT Imports: 8 Imported by: 0

README

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

Exceptions

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

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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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