This commit is contained in:
Boston Cartwright 2025-06-20 15:36:56 -04:00 committed by GitHub
commit 7c88425856
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -553,6 +553,10 @@ func Init() {
if !mustUseModules {
return
}
} else if os.Getenv("GOMOD") != "" && filepath.Join(modRoot, "go.mod") != filepath.Join(modRoot, os.Getenv("GOMOD")) {
// if GOMOD is set and does not point to module file, error as they must use -modfile
// see golang.org/issue/51217
base.Fatalf("go: GOMOD cannot be used to set the module file. use -modfile")
} else {
modRoots = []string{modRoot}
}