]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: remove auto-deriving module path for github.com
authorConstantin Konstantinidis <constantinkonstantinidis@gmail.com>
Sun, 14 Apr 2019 05:52:05 +0000 (07:52 +0200)
committerBryan C. Mills <bcmills@google.com>
Tue, 16 Apr 2019 18:31:01 +0000 (18:31 +0000)
This fix removes the special case of auto-deriving the module path
only for VCS github.com. Error message now explicitly requests
the module path. Documentation and its FAQ do not need an update
as only the beginning of the message is mentioned and is not modified.

Fixes #27951

Change-Id: Icaf87a38b5c58451edba9beaa12ae9a68e288ca1
Reviewed-on: https://go-review.googlesource.com/c/go/+/172019
Reviewed-by: Daniel Lublin <daniel@lublin.se>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/internal/modload/init.go

index d0beb6e747390246e7b93cf4c6f375e2bb15a077..4bc4a2449c71f8300efcc9c81c9ecab21ab52242 100644 (file)
@@ -559,17 +559,10 @@ func findModulePath(dir string) (string, error) {
                }
        }
 
-       // Look for .git/config with github origin as last resort.
-       data, _ = ioutil.ReadFile(filepath.Join(dir, ".git/config"))
-       if m := gitOriginRE.FindSubmatch(data); m != nil {
-               return "github.com/" + string(m[1]), nil
-       }
-
-       return "", fmt.Errorf("cannot determine module path for source directory %s (outside GOPATH, module path not specified)", dir)
+       return "", fmt.Errorf("cannot determine module path for source directory %s (outside GOPATH, module path must be specified)", dir)
 }
 
 var (
-       gitOriginRE     = lazyregexp.New(`(?m)^\[remote "origin"\]\r?\n\turl = (?:https://github.com/|git@github.com:|gh:)([^/]+/[^/]+?)(\.git)?\r?\n`)
        importCommentRE = lazyregexp.New(`(?m)^package[ \t]+[^ \t\r\n/]+[ \t]+//[ \t]+import[ \t]+(\"[^"]+\")[ \t]*\r?\n`)
 )