]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: expand cannot determine module path error
authorTyler Bui-Palsulich <tbp@google.com>
Mon, 22 Apr 2019 19:09:10 +0000 (15:09 -0400)
committerJay Conrod <jayconrod@google.com>
Mon, 22 Apr 2019 21:39:57 +0000 (21:39 +0000)
See suggestion 2 of #31543 by thepudds.

We may want to expand 'go help mod init' in the future to document what
the module path should look like.

Change-Id: Ia559fa96fda871e011d53f42a803175abc512202
Reviewed-on: https://go-review.googlesource.com/c/go/+/173318
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/modload/init.go

index fad204a2ddcc9526e6444c34a8ddd4f5c893d867..bc0541705f1f04df5c9edc2ffd87f59de0251bc8 100644 (file)
@@ -512,7 +512,8 @@ func findModulePath(dir string) (string, error) {
        // TODO(bcmills): once we have located a plausible module path, we should
        // query version control (if available) to verify that it matches the major
        // version of the most recent tag.
-       // See https://golang.org/issue/29433 and https://golang.org/issue/27009.
+       // See https://golang.org/issue/29433, https://golang.org/issue/27009, and
+       // https://golang.org/issue/31549.
 
        // Cast about for import comments,
        // first in top-level directory, then in subdirectories.
@@ -563,7 +564,15 @@ func findModulePath(dir string) (string, error) {
                }
        }
 
-       return "", fmt.Errorf("cannot determine module path for source directory %s (outside GOPATH, module path must be specified)", dir)
+       msg := `cannot determine module path for source directory %s (outside GOPATH, module path must be specified)
+
+Example usage:
+       'go mod init example.com/m' to initialize a v0 or v1 module
+       'go mod init example.com/m/v2' to initialize a v2 module
+
+Run 'go help mod init' for more information.
+`
+       return "", fmt.Errorf(msg, dir)
 }
 
 var (