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

cmd/go: -json flag for go version -m #69712

Open
hyangah opened this issue Sep 30, 2024 · 9 comments
Open

cmd/go: -json flag for go version -m #69712

hyangah opened this issue Sep 30, 2024 · 9 comments
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal Proposal-Accepted
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Sep 30, 2024

$ go version -m -json ~/go/bin/gopls
flag provided but not defined: -json
usage: go version [-m] [-v] [file ...]
Run 'go help version' for details.

VS Code Go (TS/JS) uses go version -m when inspecting the tools versions.
If go version -m can output JSON-encoded runtime/debug.BuildSetting format,
it will help simplifying output parsing a lot.

@hyangah hyangah added FeatureRequest Issues asking for a new feature that does not need a proposal. GoCommand cmd/go labels Sep 30, 2024
@gabyhelp
Copy link

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@mknyszek mknyszek added this to the Backlog milestone Sep 30, 2024
@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 30, 2024
@matloob matloob changed the title cmd/go: -json flag for go version -m proposal: cmd/go: -json flag for go version -m Oct 1, 2024
@matloob matloob added this to Proposals Oct 1, 2024
@matloob matloob moved this to Incoming in Proposals Oct 1, 2024
@matloob
Copy link
Contributor

matloob commented Oct 1, 2024

I think we should do this.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/619955 mentions this issue: cmd/go: support -json flag in go version

@xieyuschen
Copy link
Contributor

hi, could I know any update for this proposal? thanks:)

@rsc
Copy link
Contributor

rsc commented Dec 4, 2024

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc rsc moved this from Incoming to Active in Proposals Dec 4, 2024
@aclements
Copy link
Member

Seems like a good and simple addition.

What should happen if the caller passes multiple binaries? Probably the output should be a concatenation of JSON objects (not a JSON array of objects). That would be consistent with how go list -json and several other go subcommands work, and makes the common case where you know you're only passing a single binary easiest to parse.

What should happen if you pass -json without -m? Probably just reject it with an error? (go version -json was already discussed in #55136)

@matloob
Copy link
Contributor

matloob commented Dec 11, 2024

What should happen if the caller passes multiple binaries? Probably the output should be a concatenation of JSON objects (not a JSON array of objects). That would be consistent with how go list -json and several other go subcommands work, and makes the common case where you know you're only passing a single binary easiest to parse.

Yes, that sounds good.

What should happen if you pass -json without -m? Probably just reject it with an error? (go version -json was already discussed in #55136)

Yes, we should reject it.

@aclements aclements moved this from Active to Likely Accept in Proposals Jan 28, 2025
@aclements
Copy link
Member

Based on the discussion above, this proposal seems like a likely accept.
— aclements for the proposal review group

The proposal is to add a -json flag for go version -m that would print the JSON encoding of runtime/debug.BuildSetting to standard output. Specifying -json without -m would be an error. If go version is invoked with multiple binaries, the build settings for each binary will be printed on a separate line.

@rsc
Copy link
Contributor

rsc commented Feb 5, 2025

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

The proposal is to add a -json flag for go version -m that would print the JSON encoding of runtime/debug.BuildSetting to standard output. Specifying -json without -m would be an error. If go version is invoked with multiple binaries, the build settings for each binary will be printed on a separate line.

@rsc rsc moved this from Likely Accept to Accepted in Proposals Feb 5, 2025
@rsc rsc changed the title proposal: cmd/go: -json flag for go version -m cmd/go: -json flag for go version -m Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal Proposal-Accepted
Projects
Status: Accepted
Development

No branches or pull requests

8 participants