go work edit

Edit go.work from tools or scripts

Options

NameDescription
-fmtThe -fmt flag reformats the go.work file without making other changes. This reformatting is also implied by any other modifications that use or rewrite the go.mod file. The only time this flag is needed is if no other flags are specified, as in 'go work edit -fmt'
-use <path>The -use=path and -dropuse=path flags add and drop a use directive from the go.work file's set of module directories
-dropuse <path>The -use=path and -dropuse=path flags add and drop a use directive from the go.work file's set of module directories
-replace <old[@v]=new[@v]>The -replace=old[@v]=new[@v] flag adds a replacement of the given module path and version pair. If the @v in old@v is omitted, a replacement without a version on the left side is added, which applies to all versions of the old module path. If the @v in new@v is omitted, the new path should be a local module root directory, not a module path. Note that -replace overrides any redundant replacements for old[@v], so omitting @v will drop existing replacements for specific versions
-dropreplace <old[@v]>The -dropreplace=old[@v] flag drops a replacement of the given module path and version pair. If the @v is omitted, a replacement without a version on the left side is dropped
-go <version>Set the expected Go language version
-printThe -print flag prints the final go.work in its text format instead of writing it back to go.mod
-jsonThe -json flag prints the final go.work file in JSON format instead of writing it back to go.mod