Skip to content

silven/go-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example Go language project

A project to demonstrate my go project structure and Makefile setup

Usage

Structure the code into more smaller packages, nested as far as you want.

Place to-be-executables into files in the cmd directory.

Commands

  • make fmt - Formats the source code
  • make test - Runs go test on your packges
  • make bench - Runs the tests with benchmarking enabled
  • make cov - Gives you a code coverage reports
  • make vet - Runs go vet on your code trying to find errors
  • make clean - Removes any non-source files generated by the Makefile in the project
  • make cov-html - Gives you nice html with code coverage
  • make install - Installs all your library packages into $GOROOT/pkg for faster compilation
  • make "exe" - Runs the executable go file cmd/"exe".go
  • make build - Builds all the executables under ./cmd and places them in ./bin
  • make godoc - Zips up your code and launches a godoc webserver where you can browse documentation

Configuration

The only configuration needed is the two topmost variables in the Makefile

REPOSITORY	:= github.com/silven/go-example
PACKAGES 	:= common common/sub

The first one is the path to the repository, and the second lists the subpackages with go code. Leave out ./cmd

Cross Compilation

If you have used davecheney/golang-crosscompile You can cross compile using the Makefile by setting the GOOS and GOARCH before running make.

GOOS=windows GOARCH=386 make build

This feature is not very well tested, but I think it should work

About

Example Go language project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages