@@ -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
@@ -150,58 +127,47 @@ common-check_license:
150
127
.PHONY: common-deps
151
128
common-deps:
152
129
@echo ">> getting dependencies"
153
- ifdef GO111MODULE
154
- GO111MODULE=$(GO111MODULE) $(GO) mod download
155
- else
156
- $(GO) get $(GOOPTS) -t ./...
157
- endif
130
+ $(GO) mod download
158
131
159
132
.PHONY: update-go-deps
160
133
update-go-deps:
161
134
@echo ">> updating Go dependencies"
162
135
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
163
136
$(GO) get -d $$m; \
164
137
done
165
- GO111MODULE=$(GO111MODULE) $(GO) mod tidy
166
- ifneq (,$(wildcard vendor))
167
- GO111MODULE=$(GO111MODULE) $(GO) mod vendor
168
- endif
138
+ $(GO) mod tidy
169
139
170
140
.PHONY: common-test-short
171
141
common-test-short: $(GOTEST_DIR)
172
142
@echo ">> running short tests"
173
- GO111MODULE=$(GO111MODULE) $(GOTEST) -short $(GOOPTS) $(pkgs)
143
+ $(GOTEST) -short $(GOOPTS) $(pkgs)
174
144
175
145
.PHONY: common-test
176
146
common-test: $(GOTEST_DIR)
177
147
@echo ">> running all tests"
178
- GO111MODULE=$(GO111MODULE) $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
148
+ $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
179
149
180
150
$(GOTEST_DIR):
181
151
@mkdir -p $@
182
152
183
153
.PHONY: common-format
184
154
common-format:
185
155
@echo ">> formatting code"
186
- GO111MODULE=$(GO111MODULE) $(GO) fmt $(pkgs)
156
+ $(GO) fmt $(pkgs)
187
157
188
158
.PHONY: common-vet
189
159
common-vet:
190
160
@echo ">> vetting code"
191
- GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs)
161
+ $(GO) vet $(GOOPTS) $(pkgs)
192
162
193
163
.PHONY: common-lint
194
164
common-lint: $(GOLANGCI_LINT)
195
165
ifdef GOLANGCI_LINT
196
166
@echo ">> running golangci-lint"
197
- ifdef GO111MODULE
198
167
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
199
168
# Otherwise staticcheck might fail randomly for some reason not yet explained.
200
- GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
201
- GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
202
- else
203
- $(GOLANGCI_LINT) run $(pkgs)
204
- endif
169
+ $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
170
+ $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
205
171
endif
206
172
207
173
.PHONY: common-yamllint
@@ -218,28 +184,15 @@ endif
218
184
common-staticcheck: lint
219
185
220
186
.PHONY: common-unused
221
- common-unused: $(GOVENDOR)
222
- ifdef GOVENDOR
223
- @echo ">> running check for unused packages"
224
- @$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
225
- else
226
- ifdef GO111MODULE
187
+ common-unused:
227
188
@echo ">> running check for unused/missing packages in go.mod"
228
- GO111MODULE=$(GO111MODULE) $(GO) mod tidy
229
- ifeq (,$(wildcard vendor))
189
+ $(GO) mod tidy
230
190
@git diff --exit-code -- go.sum go.mod
231
- else
232
- @echo ">> running check for unused packages in vendor/"
233
- GO111MODULE=$(GO111MODULE) $(GO) mod vendor
234
- @git diff --exit-code -- go.sum go.mod vendor/
235
- endif
236
- endif
237
- endif
238
191
239
192
.PHONY: common-build
240
193
common-build: promu
241
194
@echo ">> building binaries"
242
- GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
195
+ $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
243
196
244
197
.PHONY: common-tarball
245
198
common-tarball: promu
@@ -295,12 +248,6 @@ $(GOLANGCI_LINT):
295
248
| sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
296
249
endif
297
250
298
- ifdef GOVENDOR
299
- .PHONY: $(GOVENDOR)
300
- $(GOVENDOR):
301
- GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
302
- endif
303
-
304
251
.PHONY: precheck
305
252
precheck::
306
253
0 commit comments