This script performs the build, test and automatic checking of a Go package and its sub-packages using:
- gofmt
- goimports
- golint
- go vet
- ineffassign
- race detector
- test coverage on package and its sub-packages,
/vendor
directories excluded - goveralls
- gocyclo
- misspell
Migrated from my Gist.
To setup all the dependencies need to run the script do:
$ go get -v github.com/client9/misspell/cmd/misspell
$ go get -v github.com/fzipp/gocyclo
$ go get -v github.com/golang/lint/golint
$ go get -v github.com/gordonklaus/ineffassign
$ go get -v github.com/h12w/gosweep
$ go get -v github.com/mattn/goveralls
$ go get -v golang.org/x/tools/cmd/goimports
- GOCYCLO_COMPLEXITY: maximum allowed function complexity threshold (default:
5
). - MISSPELL_LOCALE: English locale (default:
US
).
If you wish to set this for a project you can create a .gosweep
file.
For example:
$ cat .gosweep
GOCYCLO_COMPLEXITY=5
MISSPELL_LOCALE='US'
Example of .travis.yml
file for Go:
language: go
cache:
directories:
- ${GOPATH}/src/github.com/${TRAVIS_REPO_SLUG}/vendor
- ${GOPATH}/src/github.com/fzipp
- ${GOPATH}/src/github.com/golang
- ${GOPATH}/src/github.com/gordonklaus
- ${GOPATH}/src/github.com/h12w
- ${GOPATH}/src/github.com/mattn
go:
- tip
- 1.8
- 1.7
- 1.6
sudo: false
env:
CI_SERVICE=travis-ci
install:
- go get -v github.com/client9/misspell/cmd/misspell
- go get -v github.com/fzipp/gocyclo
- go get -v github.com/golang/lint/golint
- go get -v github.com/gordonklaus/ineffassign
- go get -v github.com/h12w/gosweep
- go get -v github.com/mattn/goveralls
- go get -v -u golang.org/x/tools/cmd/goimports
script:
- bash ${GOPATH}/src/github.com/h12w/gosweep/gosweep.sh