https://github.com/leighmcculloch/gochecknoinits
Check that no init functions are present in Go code.
https://github.com/leighmcculloch/gochecknoinits
Last synced: about 1 month ago
JSON representation
Check that no init functions are present in Go code.
- Host: GitHub
- URL: https://github.com/leighmcculloch/gochecknoinits
- Owner: leighmcculloch
- License: mit
- Created: 2018-05-21T14:06:14.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-16T04:37:46.000Z (about 4 years ago)
- Last Synced: 2025-04-30T16:13:46.171Z (about 1 month ago)
- Language: Go
- Size: 8.79 KB
- Stars: 41
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gochecknoinits
[](https://travis-ci.org/leighmcculloch/gochecknoinits)
[](https://goreportcard.com/report/github.com/leighmcculloch/gochecknoinits)Check that no inits functions are present in Go code.
## Why
Init functions cause an import to have 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.