@@ -36,29 +36,6 @@ GO_VERSION ?= $(shell $(GO) version)
36
36
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
37
37
PRE_GO_111 ?= $(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.(10|[0-9])\.')
38
38
39
- GOVENDOR :=
40
- GO111MODULE :=
41
- ifeq (, $(PRE_GO_111))
42
- ifneq (,$(wildcard go.mod))
43
- # Enforce Go modules support just in case the directory is inside GOPATH (and for Travis CI).
44
- GO111MODULE := on
45
-
46
- ifneq (,$(wildcard vendor))
47
- # Always use the local vendor/ directory to satisfy the dependencies.
48
- GOOPTS := $(GOOPTS) -mod=vendor
49
- endif
50
- endif
51
- else
52
- ifneq (,$(wildcard go.mod))
53
- ifneq (,$(wildcard vendor))
54
- $(warning This repository requires Go >= 1.11 because of Go modules)
55
- $(warning Some recipes may not work as expected as the current Go runtime is '$(GO_VERSION_NUMBER)')
56
- endif
57
- else
58
- # This repository isn't using Go modules (yet).
59
- GOVENDOR := $(FIRST_GOPATH)/bin/govendor
60
- endif
61
- endif
62
39
PROMU := $(FIRST_GOPATH)/bin/promu
63
40
pkgs = ./...
64
41
@@ -83,7 +60,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
83
60
84
61
GOLANGCI_LINT :=
85
62
GOLANGCI_LINT_OPTS ?=
86
- GOLANGCI_LINT_VERSION ?= v1.42.0
63
+ GOLANGCI_LINT_VERSION ?= v1.45.2
87
64
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
88
65
# windows isn't included here because of the path separator being different.
89
66
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
@@ -139,87 +116,63 @@ common-style:
139
116
.PHONY: common-deps
140
117
common-deps:
141
118
@echo ">> getting dependencies"
142
- ifdef GO111MODULE
143
- GO111MODULE=$(GO111MODULE) $(GO) mod download
144
- else
145
- $(GO) get $(GOOPTS) -t ./...
146
- endif
119
+ $(GO) mod download
147
120
148
121
.PHONY: update-go-deps
149
122
update-go-deps:
150
123
@echo ">> updating Go dependencies"
151
124
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
152
125
$(GO) get -d $$m; \
153
126
done
154
- GO111MODULE=$(GO111MODULE) $(GO) mod tidy
155
- ifneq (,$(wildcard vendor))
156
- GO111MODULE=$(GO111MODULE) $(GO) mod vendor
157
- endif
127
+ $(GO) mod tidy
158
128
159
129
.PHONY: common-test-short
160
130
common-test-short: $(GOTEST_DIR)
161
131
@echo ">> running short tests"
162
- GO111MODULE=$(GO111MODULE) $(GOTEST) -short $(GOOPTS) $(pkgs)
132
+ $(GOTEST) -short $(GOOPTS) $(pkgs)
163
133
164
134
.PHONY: common-test
165
135
common-test: $(GOTEST_DIR)
166
136
@echo ">> running all tests"
167
- GO111MODULE=$(GO111MODULE) $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
137
+ $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
168
138
169
139
$(GOTEST_DIR):
170
140
@mkdir -p $@
171
141
172
142
.PHONY: common-format
173
143
common-format:
174
144
@echo ">> formatting code"
175
- GO111MODULE=$(GO111MODULE) $(GO) fmt $(pkgs)
145
+ $(GO) fmt $(pkgs)
176
146
177
147
.PHONY: common-vet
178
148
common-vet:
179
149
@echo ">> vetting code"
180
- GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs)
150
+ $(GO) vet $(GOOPTS) $(pkgs)
181
151
182
152
.PHONY: common-lint
183
153
common-lint: $(GOLANGCI_LINT)
184
154
ifdef GOLANGCI_LINT
185
155
@echo ">> running golangci-lint"
186
- ifdef GO111MODULE
187
156
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
188
157
# Otherwise staticcheck might fail randomly for some reason not yet explained.
189
- GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
190
- GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
191
- else
192
- $(GOLANGCI_LINT) run $(pkgs)
193
- endif
158
+ $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
159
+ $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
194
160
endif
195
161
196
162
# For backward-compatibility.
197
163
.PHONY: common-staticcheck
198
164
common-staticcheck: lint
199
165
200
166
.PHONY: common-unused
201
- common-unused: $(GOVENDOR)
202
- ifdef GOVENDOR
203
- @echo ">> running check for unused packages"
204
- @$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
205
- else
206
- ifdef GO111MODULE
167
+ common-unused:
207
168
@echo ">> running check for unused/missing packages in go.mod"
208
- GO111MODULE=$(GO111MODULE) $(GO) mod tidy
209
- ifeq (,$(wildcard vendor))
169
+ $(GO) mod tidy
210
170
@git diff --exit-code -- go.sum go.mod
211
- else
212
- @echo ">> running check for unused packages in vendor/"
213
- GO111MODULE=$(GO111MODULE) $(GO) mod vendor
214
- @git diff --exit-code -- go.sum go.mod vendor/
215
- endif
216
- endif
217
- endif
218
171
219
172
.PHONY: common-build
220
173
common-build: promu
221
174
@echo ">> building binaries"
222
- GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
175
+ $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
223
176
224
177
.PHONY: common-tarball
225
178
common-tarball: promu
@@ -275,12 +228,6 @@ $(GOLANGCI_LINT):
275
228
| sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
276
229
endif
277
230
278
- ifdef GOVENDOR
279
- .PHONY: $(GOVENDOR)
280
- $(GOVENDOR):
281
- GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
282
- endif
283
-
284
231
.PHONY: precheck
285
232
precheck::
286
233
0 commit comments