-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (53 loc) · 1.2 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
GO_BIN := $(GOPATH)/bin
GOIMPORTS := $(GO_BIN)/goimports
GOLANGCI := $(GO_BIN)/golangci-lint
## build: Build an application
.PHONY: build
build: fmt
go build -v -o main
## install: Install application
.PHONY: install
install:
go install -v
## run: Run application
.PHONY: run
run: fmt
go run .
## test: Launch unit tests
.PHONY: test
test:
go test ./...
## coverage: Launch unit tests
.PHONY: coverage
coverage:
@go test -v -coverpkg=./... -coverprofile=profile.cov ./... > /dev/null
@go tool cover -func profile.cov | tail -n 1
@rm -fr profile.cov
## clean: Cleanup build artefacts
.PHONY:
clean:
go clean
## generate: Regenerate all required files
generate:
go generate
## tidy: Cleanup go.sum and go.mod files
.PHONY: tidy
tidy:
go mod tidy
## lint: Launch project linters
.PHONY: lint
lint: $(GOLANGCI)
$(GOLANGCI) run
## fmt: Reformat source code
.PHONY: fmt
fmt: $(GOIMPORTS)
$(GOIMPORTS) -w -l .
$(GOIMPORTS):
go install golang.org/x/tools/cmd/goimports@master
$(GOLANGCI):
go install github.com/golangci/golangci-lint/cmd/[email protected]
## help: Prints help message
.PHONY: help
help:
@echo "Usage: \n"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' | sort