Skip to content

Enable Go module support across all commands #717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.DEFAULT_GOAL = test
.PHONY: FORCE

# Enable Go module support across all commands.
export GO111MODULE = on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required? Go 1.13 has this on by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tariq1890 Go 1.13 defaults it to auto which implies module-awareness by default (see: https://golang.org/doc/go1.13#modules). However, the primary reason for this change is to consolidate all of the places it was being set and to force consistent module on behavior for both Go 1.12 and 1.13 builds in CI (see: https://github.com/golangci/golangci-lint/blob/master/.travis.yml#L2). FWIW, I also tested this change against Go 1.11 locally and it seemed to work fine. It may be possible to re-enable Go 1.11 in CI if there aren't any internal Go runtime/interface issues to be wary of. @jirfag Thoughts?


# Build

fast_build: FORCE
Expand All @@ -14,15 +17,12 @@ clean:
.PHONY: fast_build build build_race clean

# Test
test: export GO111MODULE = on
test: export GOLANGCI_LINT_INSTALLED = true

test: build
GL_TEST_RUN=1 time ./golangci-lint run -v
GL_TEST_RUN=1 time ./golangci-lint run --fast --no-config -v --skip-dirs 'test/testdata_etc,internal/(cache|renameio|robustio)'
GL_TEST_RUN=1 time ./golangci-lint run --no-config -v --skip-dirs 'test/testdata_etc,internal/(cache|renameio|robustio)'
GL_TEST_RUN=1 time go test -v ./...

.PHONY: test

test_race:
Expand Down Expand Up @@ -69,19 +69,19 @@ golangci-lint: FORCE pkg/logutils/mock_logutils/mock_log.go
go build -o $@ ./cmd/golangci-lint

tools/mockgen: go.mod go.sum
GOBIN=$(CURDIR)/tools GO111MODULE=on go install github.com/golang/mock/mockgen
GOBIN=$(CURDIR)/tools go install github.com/golang/mock/mockgen

tools/goimports: go.mod go.sum
GOBIN=$(CURDIR)/tools GO111MODULE=on go install golang.org/x/tools/cmd/goimports
GOBIN=$(CURDIR)/tools go install golang.org/x/tools/cmd/goimports

tools/go.mod:
@mkdir -p tools
@rm -f $@
cd tools && GO111MODULE=on go mod init local-tools
cd tools && go mod init local-tools

tools/godownloader: Makefile tools/go.mod
# https://github.com/goreleaser/godownloader/issues/133
cd tools && GOBIN=$(CURDIR)/tools GO111MODULE=off go get -u github.com/goreleaser/godownloader
cd tools && GOBIN=$(CURDIR)/tools go get -u github.com/goreleaser/godownloader

tools/svg-term:
@mkdir -p tools
Expand All @@ -106,11 +106,11 @@ pkg/logutils/mock_logutils/mock_log.go: tools/mockgen tools/goimports pkg/loguti
PATH=$(CURDIR)/tools:$${PATH} go generate ./...

go.mod: FORCE
GO111MODULE=on go mod verify
GO111MODULE=on go mod tidy
go mod tidy
go mod verify
go.sum: go.mod

.PHONY: vendor
vendor: go.mod go.sum
rm -rf vendor
GO111MODULE=on go mod vendor
go mod vendor