Skip to content
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

consul/api@v1.9.0 uses go1.16-only variable #10470

Closed
knusbaum opened this issue Jun 23, 2021 · 3 comments · Fixed by #10473
Closed

consul/api@v1.9.0 uses go1.16-only variable #10470

knusbaum opened this issue Jun 23, 2021 · 3 comments · Fixed by #10473
Labels
theme/api Relating to the HTTP API interface

Comments

@knusbaum
Copy link
Contributor

Overview of the Issue

When pulling the latest consul/api (v1.9.0) I get a build error when using go < 1.16 due to the use of io.Discard

Reproduction Steps

% go version
go version go1.14.15 darwin/amd64
% go get github.com/hashicorp/consul/api@latest
go: github.com/hashicorp/consul/api latest => v1.9.0
# github.com/hashicorp/consul/api
../../../../../../go/pkg/mod/github.com/hashicorp/consul/api@v1.9.0/api.go:1072:17: undefined: io.Discard

Fix

The go.mod file says that go1.12 is the minimum version.
To keep consul/api compatible with previous versions of Go, it should use ioutil.Discard rather than io.Discard, which was not introduced until go1.16

@dnephin
Copy link
Contributor

dnephin commented Jun 24, 2021

Thank you for the bug report!

Note the Go language policy is to only support the last two Major versions, so similarly we would only support the last two major Go versions for the api and sdk modules. Code outside of those modules (ex: command/) is not intended to be used as a library, and may only support the single version of Go we use to build Consul. However in this case making it support older versions is easy, so not a problem.

The go.mod go directive is more about communicating to the Go toolchain how to compule the binary. It's not a statement that the code works with that version of Go.

We will update our CI to test the api and sdk modules against the latest 2 Go versions (go1.15, and go1.16 at this time), to prevent similar problems in the future.

@knusbaum
Copy link
Contributor Author

Thanks, @dnephin

Would you consider releasing a v1.9.1 patch version of api, since v1.9.0 is broken with go1.15, which you say you should support?

@dnephin
Copy link
Contributor

dnephin commented Jun 29, 2021

Yes, we have tagged v1.9.1 for the api: https://github.com/hashicorp/consul/releases/tag/api%2Fv1.9.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/api Relating to the HTTP API interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants