Closed displague closed 3 years ago
Looks good. I understand that the version string in a package linking packngo comes from the build info, but I didn't get where is the version for packngo itself set. Is it coming only from git tag or github release?
@t0mk That's the best part of this - it would come from the go.mod
of the package that is bundling packngo! 😃
I have v0.14.0 in my go.mod for packet-cli, and I replace it to ../
(with the branch checked out, I gave it a testing tag of v0.15.0):
=======[REQUEST]=============
GET /metal/v1/plans HTTP/1.1
Host: api.equinix.com
User-Agent: packet-cli/devel packngo/v0.14.0
Connection: close
Accept: application/json
Content-Type: application/json
X-Auth-Token: **REDACTED**
X-Consumer-Token: Equinix Metal CLI
Accept-Encoding: gzip
I had to change UserAgent
(which is the default, not the one used by the client) from a const to a var to use the new behavior.
debug.BuildInfo is a way that we can get the packngo version dynamically at runtime. This change will allow us to make automated releases without intervening in the process to update the Version variable contained in version.go
https://golang.org/pkg/runtime/debug/#BuildInfo
https://www.reddit.com/r/golang/comments/lqkkiz/creating_dynamic_version_numbers_in_go_116/