Skip to content

Commit 75308c9

Browse files
iwdgoBryan C. Mills
authored and
Bryan C. Mills
committed
cmd/go: remove auto-deriving module path for github.com
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 <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 996a687 commit 75308c9

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -559,17 +559,10 @@ func findModulePath(dir string) (string, error) {
559559
}
560560
}
561561

562-
// Look for .git/config with github origin as last resort.
563-
data, _ = ioutil.ReadFile(filepath.Join(dir, ".git/config"))
564-
if m := gitOriginRE.FindSubmatch(data); m != nil {
565-
return "github.com/" + string(m[1]), nil
566-
}
567-
568-
return "", fmt.Errorf("cannot determine module path for source directory %s (outside GOPATH, module path not specified)", dir)
562+
return "", fmt.Errorf("cannot determine module path for source directory %s (outside GOPATH, module path must be specified)", dir)
569563
}
570564

571565
var (
572-
gitOriginRE = lazyregexp.New(`(?m)^\[remote "origin"\]\r?\n\turl = (?:https://github.com/|[email protected]:|gh:)([^/]+/[^/]+?)(\.git)?\r?\n`)
573566
importCommentRE = lazyregexp.New(`(?m)^package[ \t]+[^ \t\r\n/]+[ \t]+//[ \t]+import[ \t]+(\"[^"]+\")[ \t]*\r?\n`)
574567
)
575568

0 commit comments

Comments
 (0)