Skip to content

cmd/go: add -f (format) flag to go mod edit #34943

@josharian

Description

@josharian

go mod edit -json dumps the entire mod file. However, having to parse json immediately takes this out of the realm of simple bash scripts.

As part of working on #34867, I've already hit two cases in which I need targeted information out of go mod edit -json: The required version of a module, and all replacements involving that module.

Writing a quick program to parse json is easy, but the obvious language to use is Go. But in my circumstances, I can't go run a Go program, because the mod file is in a broken state.

I propose that, like go list, go mod edit have a format flag to enable easy information requests from a shell script.

cc @bcmills @jayconrod

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions