-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (34 loc) · 1006 Bytes
/
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
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: go-imports
go-imports: goimports
$(GOIMPORTS) -w .
.PHONY: vet
vet:
go vet ./...
.PHONY: lint
lint: golangci-lint
$(GOLANGCI_LINT) run
.PHONY: mod-tidy
mod-tidy:
go mod tidy
.PHONY: test
test:
go test ./... -race -coverprofile=coverage.out -covermode=atomic -coverpkg=./...
LOCAL_BIN ?= $(shell pwd)/bin
$(LOCAL_BIN):
mkdir -p $(LOCAL_BIN)
GOIMPORTS ?= $(LOCAL_BIN)/goimports
GOLANGCI_LINT ?= $(LOCAL_BIN)/golangci-lint
GOIMPORTS_VERSION ?= v0.16.1
GOLANGCI_LINT_VERSION ?= v1.56.2
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT): $(LOCAL_BIN)
@test -s $(GOLANGCI_LINT) && $(GOLANGCI_LINT) --version | grep -q $(GOLANGCI_LINT_VERSION) || \
GOBIN=$(LOCAL_BIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
.PHONY: goimports
goimports: $(GOIMPORTS)
$(GOIMPORTS): $(LOCAL_BIN)
@test -s $(GOIMPORTS) || GOBIN=$(LOCAL_BIN) go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION)