All Skycoin projects based upon Go should have a Makefile
that includes certain commands described below.
For reference, see the Skycoin Makefile and the Teller Makefile.
Add this to the Makefile
:
.DEFAULT_GOAL := help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
This will print a help text when invoking make
or make help
. Commands are documented by adding a comment after ##
on the same line as the command name, for example:
format: ## Formats the code
goimports -w -local github.com/skycoin/skycoin ./cmd
Invoking make
will print the following:
$ make
format Formats the code
A make format
command should use goimports
to format the source code.
A make test
command should run the tests with go test
A make lint
command should run code linters. If the code uses vendored depedencies it should call vendorcheck
. golangci-lint
should be used for code linting. Not every linter provided by golangci-lint
is required to be used. See Skycoin's golangci-lint configuration file for an example linter configuration. At the very least, the golint
, goimports
and govet
linters should be used.
make check
should invoke make lint
followed by make test
. make check
should succeed before merging code.