Commit ed7e4308 authored by Dan Peterson's avatar Dan Peterson Committed by Bryan C. Mills

cmd/go: respect -mod flag in fmt

Fixes #27841

Change-Id: Ifcfd938aff8680cf7b44dfc09fde01d6105345a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/198257
Run-TryBot: Dan Peterson <dpiddy@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
parent decf9f6f
...@@ -435,6 +435,9 @@ ...@@ -435,6 +435,9 @@
// The -n flag prints commands that would be executed. // The -n flag prints commands that would be executed.
// The -x flag prints commands as they are 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. // To run gofmt with specific options, run gofmt itself.
// //
// See also: go fix, go vet. // See also: go fix, go vet.
......
...@@ -33,3 +33,8 @@ func AddBuildFlagsNX(flags *flag.FlagSet) { ...@@ -33,3 +33,8 @@ func AddBuildFlagsNX(flags *flag.FlagSet) {
flags.BoolVar(&cfg.BuildN, "n", false, "") flags.BoolVar(&cfg.BuildN, "n", false, "")
flags.BoolVar(&cfg.BuildX, "x", 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", "", "")
}
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
func init() { func init() {
base.AddBuildFlagsNX(&CmdFmt.Flag) base.AddBuildFlagsNX(&CmdFmt.Flag)
base.AddLoadFlags(&CmdFmt.Flag)
} }
var CmdFmt = &base.Command{ var CmdFmt = &base.Command{
...@@ -38,6 +39,9 @@ For more about specifying packages, see 'go help packages'. ...@@ -38,6 +39,9 @@ For more about specifying packages, see 'go help packages'.
The -n flag prints commands that would be executed. The -n flag prints commands that would be executed.
The -x flag prints commands as they are 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. To run gofmt with specific options, run gofmt itself.
See also: go fix, go vet. See also: go fix, go vet.
......
...@@ -63,6 +63,7 @@ go build ...@@ -63,6 +63,7 @@ go build
go build -mod=vendor go build -mod=vendor
go test -mod=vendor . ./subdir go test -mod=vendor . ./subdir
go test -mod=vendor ./... go test -mod=vendor ./...
go fmt -mod=vendor ./...
-- go.mod -- -- go.mod --
module m module m
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment