GoLang: consul/api modul


how could I use github.com/hashicorp/consul/api after version 1.4.0 in my go.mod?

In this version currently 4 CVE with the category CRITICAL.
pkg.go.dev shows that there are version up to 1.4.5 but they are not downloadable.

Is there some special trick?
There are no api changes between consul 1.4 and 1.7?

Sorry if it’s a duplicate post, my search didn’t showed something.


Hi @MarcelHillmann,

Thanks for posting about this. I had to get some information about this, as it’s a bit confusing.

To answer your question; the most up-to-date code for the API package is 1.4.0. If you go to https://pkg.go.dev/github.com/hashicorp/consul/api?tab=versions, you can see the page has 2 subheadings: Versions in this module and Other modules containing this package.
Other modules containing this package is what you want, so scroll to the bottom

For additional context, the confusion here happens because of us splitting up how split out the API package into a Go submodule with its own go.mod .
Prior to this, if you wanted to use the API package in your own go.mod , you would need to depend on the entirety of the Consul project and all of its many dependencies. Once we split the API package into a Go submodule with its own go.mod , you could depend on just the small subset of dependencies required for the relatively light API package.
You can see this between the split of github.com/hashicorp/consul/ @1.4.4 on Mar 20, 2019 and github.com/hashicorp/consul/api @1.0.0 on Mar 26, 2019.

Since 3/26, the api module has then been independently updated. Since then, the most recent version of the API module is v1.4.0 – Feb 11, 2020.

I can’t confirm on a specific time frame, but it looks like a 1.5 API could be available eventually. I ran the command git diff api/v1.4.0 v1.7.3 --compact-summary | grep api and can see that there are changes to the API.

api/acl.go                                         |  26 +
api/acl_test.go                                    |  35 +
api/agent_test.go                                  |  29 +-
api/go.sum                                         |   2 -
website/source/api/acl/policies.html.md            |  53 +
website/source/api/libraries-and-sdks.html.md      |   3 +
website/source/api/session.html.md                 |   2 +-

Please let me know if this answers your questions.
Happy Coding!