blob: 9c8329e2f3181913e2019aeba815125b8232f461 [file] [log] [blame]
Scott Bakered4efab2020-01-13 19:12:25 -08001export GO111MODULE=on
2
3default: fmt vet errcheck test lint
4
5# Taken from https://github.com/codecov/example-go#caveat-multiple-files
6.PHONY: test
7test:
8 echo "mode: atomic" > coverage.txt
9 for d in `go list ./...`; do \
10 go test -p 1 -v -timeout 6m -race -coverprofile=profile.out -covermode=atomic $$d || exit 1; \
11 if [ -f profile.out ]; then \
12 tail +2 profile.out >> coverage.txt; \
13 rm profile.out; \
14 fi \
15 done
16
17GOLINT := $(shell command -v golint)
18
19.PHONY: lint
20lint:
21ifndef GOLINT
22 go get golang.org/x/lint/golint
23endif
24 go list ./... | xargs golint
25
26.PHONY: vet
27vet:
28 go vet ./...
29
30ERRCHECK := $(shell command -v errcheck)
31# See https://github.com/kisielk/errcheck/pull/141 for details on ignorepkg
32.PHONY: errcheck
33errcheck:
34ifndef ERRCHECK
35 go get github.com/kisielk/errcheck
36endif
37 errcheck -ignorepkg fmt github.com/Shopify/sarama/...
38
39.PHONY: fmt
40fmt:
41 @if [ -n "$$(go fmt ./...)" ]; then echo 'Please run go fmt on your code.' && exit 1; fi
42
43.PHONY : install_dependencies
44install_dependencies: get
45
46.PHONY: get
47get:
48 go get -v ./...
49
50.PHONY: clean
51clean:
52 go clean ./...
53
54.PHONY: tidy
55tidy:
56 go mod tidy -v