MCPcopy Index your code
hub / github.com/leighmcculloch/gochecknoglobals

github.com/leighmcculloch/gochecknoglobals @v0.2.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.2 ↗ · + Follow
27 symbols 49 edges 20 files 6 documented · 22% 64 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

gochecknoglobals

test 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 or Err prefix that implement the error interface * Variables named _ * Variables named version * Variables assigned from regexp.MustCompile() * Variables with a //go:embed comment

Install

go install 4d63.com/gochecknoglobals@latest

Usage

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 are checked but can be excluded by adding the -test=false flag.

gochecknoglobals -test=false [package]

Core symbols most depended-on inside this repo

Analyzer
called by 3
checknoglobals/check_no_globals.go
isAllowed
called by 3
checknoglobals/check_no_globals.go
isAllowedSelectorExpression
called by 2
checknoglobals/check_no_globals.go
hasEmbedComment
called by 2
checknoglobals/check_no_globals.go
isError
called by 1
checknoglobals/check_no_globals.go
looksLikeError
called by 1
checknoglobals/check_no_globals.go
implementsError
called by 1
checknoglobals/check_no_globals.go
identHasEmbedComment
called by 1
checknoglobals/check_no_globals.go

Shape

Function 14
Method 8
Struct 4
TypeAlias 1

Languages

Go100%

Modules by API surface

checknoglobals/check_no_globals.go10 symbols
checknoglobals/testdata/src/7/code.go9 symbols
checknoglobals/testdata/src/8/code.go3 symbols
checknoglobals/check_no_globals_test.go2 symbols
main.go1 symbols
checknoglobals/testdata/src/4/subpkg/code_0.go1 symbols
checknoglobals/testdata/src/3/code_0.go1 symbols

For agents

$ claude mcp add gochecknoglobals \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact