Skip to content
Check that no init functions are present in Go code.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
testdata Ignore tests by default May 28, 2018
.gitignore Initial commit May 21, 2018
.travis.yml Add travis ci May 22, 2018
LICENSE Initial commit May 21, 2018
README.md Ignore tests by default May 28, 2018
check_no_init.go Ignore tests by default May 28, 2018
check_no_init_test.go Ignore tests by default May 28, 2018
main.go Ignore tests by default May 28, 2018

README.md

gochecknoinits

Build Status Codecov Go Report Card

Check that no inits functions are present in Go code.

Why

Init functions cause an import to have a side effects, and side effects are hard to test, reduce 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/gochecknoinits

Usage

gochecknoinits
gochecknoinits ./...
gochecknoinits [path] [path] [path] [etc]

Add -t to include tests.

gochecknoinits -t [path]

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

You can’t perform that action at this time.