forked from vesoft-inc/go-pkg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
66 lines (51 loc) · 1.51 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
export GO111MODULE := on
GOOS := $(if $(GOOS),$(GOOS),linux)
GOARCH := $(if $(GOARCH),$(GOARCH),amd64)
GOENV := GO15VENDOREXPERIMENT="1" CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH)
GO := $(GOENV) go
GO_BUILD := $(GO) build -trimpath
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
all: check
go-generate: $(GOBIN)/mockgen
go generate ./...
check: tidy fmt vet imports lint
tidy:
go mod tidy
fmt: $(GOBIN)/gofumpt
# go fmt ./...
$(GOBIN)/gofumpt -w -l ./
vet:
go vet ./...
imports: $(GOBIN)/goimports $(GOBIN)/impi
$(GOBIN)/impi --local github.com/vesoft-inc --scheme stdLocalThirdParty \
-ignore-generated ./... \
|| exit 1
lint: $(GOBIN)/golangci-lint
$(GOBIN)/golangci-lint run
test:
# TODO: add -race arguments
go test -coverprofile=coverage.txt -covermode=atomic ./...
tools: $(GOBIN)/goimports \
$(GOBIN)/impi \
$(GOBIN)/gofumpt \
$(GOBIN)/golangci-lint \
$(GOBIN)/controller-gen \
$(GOBIN)/mockgen
$(GOBIN)/goimports:
go install golang.org/x/tools/cmd/[email protected]
$(GOBIN)/impi:
go install github.com/pavius/impi/cmd/[email protected]
$(GOBIN)/gofumpt:
go install mvdan.cc/[email protected]
$(GOBIN)/golangci-lint:
@[ -f $(GOBIN)/golangci-lint ] || { \
set -e ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.48.0 ;\
}
$(GOBIN)/mockgen:
go install github.com/golang/mock/[email protected]