1# Targets:
2#
3#   all:          Builds the code locally after testing
4#
5#   fmt:          Formats the source files
6#   fmt-check:    Check if the source files are formated
7#   build:        Builds the code locally
8#   vet:          Vets the code
9#   lint:         Runs lint over the code (you do not need to fix everything)
10#   test:         Runs the tests
11#   cover:        Gives you the URL to a nice test coverage report
12#
13#   install:      Builds, tests and installs the code locally
14
15GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")
16
17.PHONY: all fmt build vet lint test cover install
18
19# The first target is always the default action if `make` is called without
20# args we build and install into $GOPATH so that it can just be run
21
22all: fmt vet test install
23
24fmt:
25	@gofmt -s -w ${GOFILES_NOVENDOR}
26
27fmt-check:
28	@([ -z "$(shell gofmt -d $(GOFILES_NOVENDOR) | head)" ]) || (echo "Source is unformatted"; exit 1)
29
30build:
31	@go build
32
33vet:
34	@go vet
35
36lint:
37	@golint *.go
38
39test:
40	@go test -v ./...
41
42cover: COVERAGE_FILE := coverage.out
43cover:
44	@go test -coverprofile=$(COVERAGE_FILE) && \
45	cover -html=$(COVERAGE_FILE) && rm $(COVERAGE_FILE)
46
47install:
48	@go install ./...
49