Skip to content

Commit

Permalink
cmd/go: expand cannot determine module path error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tbpg authored and Jay Conrod committed Apr 22, 2019
1 parent e6ae4e8 commit 1f0c102
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/cmd/go/internal/modload/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 1f0c102

Please sign in to comment.