globals

command module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: MIT Imports: 8 Imported by: 0

README

globals

A command-line tool to help you identify and reduce global state on your Go source code (global variables and init() functions).

By default this tool doesn't report global variables for errors and regular expressions (regex).

Install

go install github.com/henvic/globals@latest

Usage

Run the tool in your project directory to list all global variables:

$ globals ./...

Some flags are available:

$ globals -h
Usage of globals:
  -include-errors
    	don't omit global variables of type error
  -include-regexp
    	don't omit global variables of type *regexp.Regexp (regular expressions)
  -test
    	indicates whether test files should be analyzed, too (default true)
  -inits
    	report init functions (default true)
  -vars
    	report global variables (default true)

Example output

$ globals ./...
main.go:8: init function
main.go:12: init function
main.go:14: var Enabled
main.go:16: var Configuration

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