gomk
gomk copied to clipboard
An opinionated Makefile for Go projects.
GoMk
An opinionated Makefile for Go projects.
Use cases
- How would you implement a building workflow using Go alongside other technologies?
- Do you remember how to run the commands to check the test coverage of you Go project?
Usage
- Download
go.mkto your project:
curl -O https://raw.githubusercontent.com/hgfischer/gomk/master/go.mk
include go.mkin a new or existing Makefile;- Check
Makefile.sampleto see some examples on how to integrate with your own build workflow:
curl -O https://raw.githubusercontent.com/hgfischer/gomk/master/Makefile.sample
How it works
GoMk defines default variables and targets for a Go project, to help maintain a healthy project. It also checks your current Go environment.
Predefined variables
APPBIN: name of the application, based on the repository nameGOSOURCES: all.gofiles inside the project repositoryGOPKGS: all Go pkgs inside the project repository
NOTE: Check the go.mk file for other predefined variables that may conflict with other variables defined in your Makefile.
Predefined targets
gomkbuild: build the application binary, if there is onegomkxbuild: build all cross-platform binaries, usinggoxgomkclean: clean the project directory of the files produced by go.mkgomkupdate: update your go.mk filevet: rungo tool vetin each source filelint: rungolintin each source filefmt: rungo fmtin the entire projecttest: rungo testfor all pkgs in the projectrace: rungo testwith race detection in all pkgs in the projectdeps: install all deps needed by the projectcover: run tests with coverage report in all pkgs in the projectsprintvars: print all variables defined in the Makefile
Godep support (optional)
savegodeps: save all deps with godeprestoregodeps: restore all deps with godepupdategodeps: update all deps with godep
TODO
- Add targets for other tools
- Add support for
gb