aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/load.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2019-02-13 17:37:50 -0500
committerBryan C. Mills <bcmills@google.com>2019-02-15 17:32:07 +0000
commit65c2069a9f30cb6fa2c512d17dc0ad654d621da9 (patch)
tree0db5138f041fb3adcb3257a23666b598a5436180 /src/cmd/go/internal/modload/load.go
parent4c89a10fb9f4fcb2ed01b6e7325e53b4bc487fc2 (diff)
downloadgo-65c2069a9f30cb6fa2c512d17dc0ad654d621da9.tar.gz
go-65c2069a9f30cb6fa2c512d17dc0ad654d621da9.zip
cmd/go: only generate a go.mod file during 'go mod init'
In the general case, we do not know the correct module path for a new module unless we have checked its VCS tags for a major version. If we do not know the correct path, then we should not synthesize a go.mod file automatically from it. On the other hand, we don't want to run VCS commands in the working directory without an explicit request by the user to do so: 'go mod init' can reasonably invoke a VCS command, but 'go build' should not. Therefore, we should only create a go.mod file during 'go mod init'. This change removes the previous behavior of synthesizing a file automatically, and instead suggests a command that the user can opt to run explicitly. Updates #29433 Updates #27009 Updates #30228 Change-Id: I8c4554969db17156e97428df220b129a4d361040 Reviewed-on: https://go-review.googlesource.com/c/162699 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r--src/cmd/go/internal/modload/load.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go
index 5bb943dd6d..6d6c037af2 100644
--- a/src/cmd/go/internal/modload/load.go
+++ b/src/cmd/go/internal/modload/load.go
@@ -111,7 +111,7 @@ func ImportPaths(patterns []string) []*search.Match {
} else {
pkg = Target.Path + suffix
}
- } else if sub := search.InDir(dir, cfg.GOROOTsrc); sub != "" && !strings.Contains(sub, "@") {
+ } else if sub := search.InDir(dir, cfg.GOROOTsrc); sub != "" && sub != "." && !strings.Contains(sub, "@") {
pkg = filepath.ToSlash(sub)
} else if path := pathInModuleCache(dir); path != "" {
pkg = path