From 54529d9e5067e02ccd9711b38d74972c4b82ca57 Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Sun, 25 Aug 2019 15:45:06 +0700 Subject: [PATCH 1/2] Fix golint installation, version tools golint changed its import path [1], and that along with the advent of modules caused fallout [2, 3] that broke the `go get -u` installation in our makefile/CI build. The tools.go idiom is the currently favored approach for versioning development tools with the module system [4, 5], in a way that `go mod tidy` won't churn them from `go.mod` and the `+build` constraint keeps them out of actual build products. The tools still need to be `go install`ed, within a module `go get -u` is not the thing to do anymore because it upgrades transitive deps of a tool which may change the module's build. It takes like hours of reading discussions to triangulate on these moving targets... [5, 6, 7, 8] jfc how much of life have I spent following the fashion evolution of Go dependency management [1]: https://github.com/golang/lint/commit/c363707d68842c977f911634e06201907b60ce58 [2]: https://github.com/golang/go/issues/30455 [3]: https://github.com/golang/go/issues/30831 [4]: https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module [5]: https://github.com/golang/go/issues/25922 [6]: https://github.com/golang/go/issues/27653 [7]: https://github.com/golang/go/issues/27643 [8]: https://github.com/golang/go/issues/30515 --- Makefile | 6 +++--- go.mod | 3 +++ go.sum | 18 ++++++++++++++++++ tools.go | 12 ++++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 tools.go diff --git a/Makefile b/Makefile index d722f6d..06b8e4d 100644 --- a/Makefile +++ b/Makefile @@ -44,13 +44,13 @@ zen: get-devtools: @echo Getting golint... - $(GO) get -u github.com/golang/lint/golint + $(GO) install golang.org/x/lint/golint @echo Getting errcheck... - $(GO) get -u github.com/kisielk/errcheck + $(GO) install github.com/kisielk/errcheck get-reltools: @echo Getting gox... - $(GO) get -u github.com/mitchellh/gox + $(GO) install github.com/mitchellh/gox dist: test @echo Cross-compiling binaries... diff --git a/go.mod b/go.mod index 1f656b6..e17a0db 100644 --- a/go.mod +++ b/go.mod @@ -7,11 +7,14 @@ require ( github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/kisielk/errcheck v1.2.0 github.com/mattn/go-isatty v0.0.4 // indirect + github.com/mitchellh/gox v1.0.1 github.com/onsi/ginkgo v1.6.0 github.com/onsi/gomega v1.4.2 github.com/pmezard/go-difflib v1.0.0 // indirect github.com/sergi/go-diff v1.0.0 // indirect github.com/stretchr/testify v1.2.2 // indirect + golang.org/x/lint v0.0.0-20190409202823-959b441ac422 gopkg.in/alecthomas/kingpin.v2 v2.2.2 ) diff --git a/go.sum b/go.sum index dec1862..5e361a3 100644 --- a/go.sum +++ b/go.sum @@ -14,10 +14,18 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8= +github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/kisielk/errcheck v1.2.0 h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= +github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= +github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I= @@ -28,14 +36,24 @@ github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd h1:/e+gpKk9r3dJobndpTytxS2gOy6m5uvpg+ISQoEcusQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/alecthomas/kingpin.v2 v2.2.2 h1:VBV8OzdyP4EuRQy9lkr5gkIGaGt5FRC0JH/+TmQVfd8= gopkg.in/alecthomas/kingpin.v2 v2.2.2/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/tools.go b/tools.go new file mode 100644 index 0000000..160e9fc --- /dev/null +++ b/tools.go @@ -0,0 +1,12 @@ +// +build tools + +// Package tools manages development tool versions through the module system. +// +// See https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module +package tools + +import ( + _ "github.com/kisielk/errcheck" + _ "github.com/mitchellh/gox" + _ "golang.org/x/lint/golint" +) From 759c155b73e1382acbae527563eb6458df19def9 Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Sun, 25 Aug 2019 17:10:13 +0700 Subject: [PATCH 2/2] Enable errcheck, Go 1.12 for Travis errcheck support for modules has been fixed. --- .travis.yml | 3 ++- Makefile | 8 ++++---- README.md | 4 ++-- err-excludes.txt | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 err-excludes.txt diff --git a/.travis.yml b/.travis.yml index b64bfa6..53594c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: go go: - 1.11 + - 1.12 - tip env: @@ -13,7 +14,7 @@ install: - export PATH=$PATH:$GOPATH/bin script: - - make lint coverage + - make check coverage after_success: - | diff --git a/Makefile b/Makefile index 06b8e4d..b41bc5d 100644 --- a/Makefile +++ b/Makefile @@ -31,13 +31,13 @@ coverage: browse-coverage: coverage $(GO) tool cover --html connect.coverprofile +check: lint errcheck + lint: golint --set_exit_status ./... -# Now it needs to be fixed for modules: -# https://github.com/kisielk/errcheck/issues/155 errcheck: - errcheck --asserts --ignore 'io:Close' $(packages) + errcheck --asserts --exclude=err-excludes.txt $(packages) zen: ginkgo watch -notify $(packages) @@ -93,5 +93,5 @@ distclean: clean $(GO) clean -i $(packages) .PHONY: build install test spec coverage browse-coverage -.PHONY: lint errcheck zen get-devtools +.PHONY: check lint errcheck zen get-devtools .PHONY: dist get-reltools man release diff --git a/README.md b/README.md index f37f8ae..8b1ddf6 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ $ go test # etc. ``` Note that you _do not_ need to use a workspace, i.e. `$GOPATH`. In fact, you -should not, or else you'll need to set `GO111MODULE=1` in your shell +should not, or else you'll need to set `GO111MODULE=on` in your shell environment to force module-aware mode on. Cross-compiling is again standard Go procedure: set `GOOS` and `GOARCH`. For @@ -206,7 +206,7 @@ files, etc. you'll need to install it using: To use the Go library, simply use `go get` and import it in your code as usual: ```sh -$ go get -u github.com/go-kafka/connect +$ go get github.com/go-kafka/connect ``` The library has no dependencies beyond the standard library. Dependencies in diff --git a/err-excludes.txt b/err-excludes.txt new file mode 100644 index 0000000..b4b6291 --- /dev/null +++ b/err-excludes.txt @@ -0,0 +1 @@ +(io.ReadCloser).Close