This is a quick project to help creating a cleaner sub directory structure in a golang project
To keep the working dir clean, generally you can do the following in the beginning in your shell:
export GOPATH=`pwd`
export PATH=$PATH:$GOPATH/bin
-
Test individual package:
go test -v github.com/user/package1 -
Run all tests recursively in your packages:
go test -v github.com/user/... ( the 3 dots are to run tests recursively ) -
Definte the parallelism with which the tests would run:
go test -p 1 -v github.com/user/... ( In case you want your tests to run with parallelism 1, for e.g. issues when you have database connections and you want to maintain the integrity. ) -
Run your
mainpackage:go install github.com/user/ userIn cae you did not find
userexecutable inpwdlook in thebindirectory. -
If you want to build the current project with a different binary:
go build -i -o mybinary github.com/user ( -i will build all the dependencies as well) ./mybinary -
To publish a coverage report for all the packages in your project:
go test -v github.com/user/... -coverFor just one package:
go test -v github.com/user/package1 -cover -
This following tool generates detailed coverage report in a very readable format:
go get github.com/axw/gocov/gocovand then run to generate test coverage for one package:
gocov test -v github.com/user/datastructs -cover | gocov reportto check detailed coverage for entire project:
gocov test -v github.com/user/... -cover | gocov report