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

proposal: cmd/go: let programs access it's go module version #27370

Closed
smyrman opened this issue Aug 30, 2018 · 2 comments
Closed

proposal: cmd/go: let programs access it's go module version #27370

smyrman opened this issue Aug 30, 2018 · 2 comments

Comments

@smyrman
Copy link

smyrman commented Aug 30, 2018

Please answer these questions before submitting your issue. Thanks!

This is a proposal so that when installing binaries via the go modules, the program is able to read and display information about the installed version of the program in a standardized manner if it's installed via go get path@version.

What version of Go are you using (go version)?

go version go1.11 darwin/amd64

What did you do?

Install a binary at a particular version. To work-around #24250, install it via a temporary go module:

mkdir test
cd test
mod init test
go get github.com/go-task/[email protected] 
go get github.com/go-task/task/cmd/[email protected]
task --version

What did you expect to see?

I did not expect to see this, but I would like for it to become possible for an application to access and display version information when installed via go get through some standardized mechanism:

$ task --version
task v.2.0.3
Git commit: 467c4360ca80d671278d287333aa6f11e5d04871

What did you see instead?

Output from --version

master

Implementation

For consistency reasons, the implementation should perhaps be similar to that of the runtime.GOOS and runtime.GOARCH constants. SCM information and other metadata except for the version, e.g. the module name, could optionally be exposed.

https://golang.org/pkg/runtime/#pkg-constants

The discussion on #26420 may be relevant.

@gopherbot gopherbot added this to the Proposal milestone Aug 30, 2018
@mvdan
Copy link
Member

mvdan commented Aug 30, 2018

This is likely a duplicate of #26404, which has been part of the design for a while.

@smyrman
Copy link
Author

smyrman commented Aug 30, 2018

Thanks -- closing as duplicate of #26404.

@smyrman smyrman closed this as completed Aug 30, 2018
@golang golang locked and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants