Skip to content

cmd/go: consider including Go's own version in 'go env' #41116

Closed
@mvdan

Description

@mvdan

go env -json tells me a lot about the user's Go setup and environment, and in a format that's easy to parse. Unfortunately, go version is missing there, so if I want to fetch that I need a separate exec call.

I wonder if we could add it to go env, similar to other "not really an env var" lines like GOMOD, GOEXE, or GOHOSTARCH. For example:

$ go version
go version go1.15 linux/amd64
$ go env -json
[...]
    "GOVERSION": "go1.15",
[...]

It would not include the string prefix go version, since it's redundant, nor the linux/amd64 pair, since that's already as GOHOSTOS/GOHOSTARCH in go env.

I'm not making this a proposal for now, since the idea seems pretty simple.

/cc @bcmills @jayconrod @matloob for cmd/go

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeGoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions