Skip to content

Commit

Permalink
cmd/go: respect -mod flag in fmt
Browse files Browse the repository at this point in the history
Fixes golang#27841

Change-Id: Ifcfd938aff8680cf7b44dfc09fde01d6105345a0
  • Loading branch information
danp committed Oct 1, 2019
1 parent a49067a commit edd7538
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cmd/go/internal/base/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ func AddBuildFlagsNX(flags *flag.FlagSet) {
flags.BoolVar(&cfg.BuildN, "n", false, "")
flags.BoolVar(&cfg.BuildX, "x", false, "")
}

// AddLoadFlags adds the -mod build flag to the flag set.
func AddLoadFlags(flags *flag.FlagSet) {
flags.StringVar(&cfg.BuildMod, "mod", "", "")
}
4 changes: 4 additions & 0 deletions src/cmd/go/internal/fmtcmd/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

func init() {
base.AddBuildFlagsNX(&CmdFmt.Flag)
base.AddLoadFlags(&CmdFmt.Flag)
}

var CmdFmt = &base.Command{
Expand All @@ -38,6 +39,9 @@ For more about specifying packages, see 'go help packages'.
The -n flag prints commands that would be executed.
The -x flag prints commands as they are executed.
The -mod flag's value sets which module download mode
to use: readonly or vendor. See 'go help modules' for more.
To run gofmt with specific options, run gofmt itself.
See also: go fix, go vet.
Expand Down

0 comments on commit edd7538

Please sign in to comment.