mirror of
https://github.com/golang/go
synced 2024-11-17 06:04:47 -07:00
cmd/go: add 'go generate' commands to modfile_flag test
Verify that 'go generate' works with -modfile. Also check that go commands starts with 'go generate' do not inherit -modfile, but they should still work if -modfile is set in GOFLAGS. Updates #34506 Change-Id: I5e1f897b4e38e4fdaccc0fbb7a71b8d0e9fc0660 Reviewed-on: https://go-review.googlesource.com/c/go/+/208236 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
3922c006ad
commit
300f5d5b4b
19
src/cmd/go/testdata/script/modfile_flag.txt
vendored
19
src/cmd/go/testdata/script/modfile_flag.txt
vendored
@ -44,6 +44,19 @@ exists vendor
|
||||
go mod edit -require rsc.io/quote@v1.5.1
|
||||
! go list .
|
||||
go list -mod=mod
|
||||
rm vendor
|
||||
|
||||
|
||||
# 'go generate' should use the alternate file when resolving packages.
|
||||
# Recursive go commands started with 'go generate' should not get an explicitly
|
||||
# passed -modfile, but they should see arguments from GOFLAGS.
|
||||
cp go.alt.mod go.gen.mod
|
||||
env OLD_GOFLAGS=$GOFLAGS
|
||||
env GOFLAGS=-modfile=go.gen.mod
|
||||
go generate -modfile=go.alt.mod .
|
||||
env GOFLAGS=$OLD_GOFLAGS
|
||||
grep example.com/exclude go.gen.mod
|
||||
! grep example.com/exclude go.alt.mod
|
||||
|
||||
|
||||
# The original files should not have been modified.
|
||||
@ -62,6 +75,10 @@ stderr '-modfile=goaltmod: file does not have .mod extension'
|
||||
-- go.sum --
|
||||
ʕ◔ϖ◔ʔ
|
||||
-- use.go --
|
||||
package use
|
||||
package main
|
||||
|
||||
import _ "rsc.io/quote"
|
||||
-- gen.go --
|
||||
//go:generate go mod edit -exclude example.com/exclude@v1.0.0
|
||||
|
||||
package main
|
||||
|
Loading…
Reference in New Issue
Block a user