I’m exploring a way to determine the version (or pseudo-version) of an application module. For example, let’s say I clone kubernetes and from that local clone I’d like go to display the version as determined by go.
It seem that the only way I can do that is by using go get directly:
$ go get -d github.com/Dreamacro/clash@34338e7107c1868124f8aab2446f6b71c9b0640f
...
go: downloading github.com/Dreamacro/clash v0.15.0
go: extracting github.com/Dreamacro/clash v0.15.0
...
See how go automatically determined version v0.15.0 from the commit 34338e7107c1868124f8aab2446f6b71c9b0640f.
The problem I’m facing is that I already have the repository cloned, so using go get seems wasteful. For very large repos, it is unacceptable in my use case.
Don’t quite getting you. Can you use git clone k9n repository then git tag --list or git log? Another way is to view their github repository for getting information?
go get is like a tool to clone repository, go build the binary (if any), go install into GOBIN (if any), all under a single command. You only use it to download binary. It’s not a one tool does everything though.
Go cmd has the functionality to determine the pseudo version for a repo, but it doesn’t seem to expose it in a way that doesn’t require re-fetching it.