mirror of
https://github.com/golang/go
synced 2024-11-18 13:04:46 -07:00
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: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
decf9f6fef
commit
ed7e43085e
@ -435,6 +435,9 @@
|
||||
// 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.
|
||||
|
@ -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", "", "")
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
|
||||
func init() {
|
||||
base.AddBuildFlagsNX(&CmdFmt.Flag)
|
||||
base.AddLoadFlags(&CmdFmt.Flag)
|
||||
}
|
||||
|
||||
var CmdFmt = &base.Command{
|
||||
@ -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.
|
||||
|
1
src/cmd/go/testdata/script/mod_vendor.txt
vendored
1
src/cmd/go/testdata/script/mod_vendor.txt
vendored
@ -63,6 +63,7 @@ go build
|
||||
go build -mod=vendor
|
||||
go test -mod=vendor . ./subdir
|
||||
go test -mod=vendor ./...
|
||||
go fmt -mod=vendor ./...
|
||||
|
||||
-- go.mod --
|
||||
module m
|
||||
|
Loading…
Reference in New Issue
Block a user