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: -json flag for go version -m #69712

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

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

hyangah opened this issue Sep 30, 2024 · 7 comments
Labels
FeatureRequest GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal
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.

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal
Projects
Status: Active
Development

No branches or pull requests

8 participants