-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
40 lines (30 loc) · 1.36 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Define packages path
PACKAGES_PATH = $(shell go list -f '{{ .Dir }}' ./...)
.PHONY: all require tidy fmt goimports vet staticcheck govulncheck test
all: require tidy fmt goimports vet staticcheck govulncheck test
require:
@type "goimports" > /dev/null 2>&1 || (echo 'goimports not found: to install it, run "go install golang.org/x/tools/cmd/goimports@latest"'; exit 1)
@type "staticcheck" > /dev/null 2>&1 || (echo 'staticcheck not found: to install it, run "go install honnef.co/go/tools/cmd/staticcheck@latest"'; exit 1)
@type "govulncheck" > /dev/null 2>&1 || (echo 'govulncheck not found: to install it, run "go install golang.org/x/vuln/cmd/govulncheck@latest"'; exit 1)
@type "gocyclo" > /dev/null 2>&1 || (echo 'gocyclo not found: to install it, run "go install github.com/fzipp/gocyclo/cmd/gocyclo@latest"'; exit 1)
@type "golangci-lint" > /dev/null 2>&1 || (echo 'golangci-lint not found: to install it, run "brew install golangci-lint"'; exit 1)
tidy:
@echo "=> Executing go mod tidy"
@go mod tidy
fmt:
@echo "=> Executing go fmt"
@go fmt ./...
goimports:
@echo "=> Executing goimports"
@goimports -w $(PACKAGES_PATH)
vet:
@echo "=> Executing go vet"
@go vet ./...
staticcheck:
@echo "=> Executing staticcheck"
@staticcheck ./...
govulncheck:
@echo "=> Executing govulncheck"
@govulncheck ./... || true
test:
@go test -v ./... -coverprofile=coverage.out