]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: update 'go help mod init'
authorJay Conrod <jayconrod@google.com>
Mon, 12 Oct 2020 16:03:43 +0000 (12:03 -0400)
committerJay Conrod <jayconrod@google.com>
Mon, 16 Nov 2020 22:24:14 +0000 (22:24 +0000)
'go help mod init' now mentions that the module path can be derived
from the directory within GOPATH. We no longer mention version
control, since that's now ignored.

Fixes #36775

Change-Id: Ia5559ecb537fccd838eeab84517e76aa01989292
Reviewed-on: https://go-review.googlesource.com/c/go/+/261539
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/go/alldocs.go
src/cmd/go/internal/modcmd/init.go

index 47076570a66c173a32ad0e4723a687ad0064798a..81f404c0eff5a7451d8d618415ec12214d3d9c86 100644 (file)
 //
 //     go mod init [module]
 //
-// Init initializes and writes a new go.mod to the current directory,
-// in effect creating a new module rooted at the current directory.
-// The file go.mod must not already exist.
-// If possible, init will guess the module path from import comments
-// (see 'go help importpath') or from version control configuration.
-// To override this guess, supply the module path as an argument.
+// Init initializes and writes a new go.mod file in the current directory, in
+// effect creating a new module rooted at the current directory. The go.mod file
+// must not already exist.
+//
+// Init accepts one optional argument, the module path for the new module. If the
+// module path argument is omitted, init will attempt to infer the module path
+// using import comments in .go files, vendoring tool configuration files (like
+// Gopkg.lock), and the current directory (if in GOPATH).
+//
+// If a configuration file for a vendoring tool is present, init will attempt to
+// import module requirements from it.
 //
 //
 // Add missing and remove unused modules
index 7384f3f293afcc776e7a3e4a17f8491994a1f074..c081bb547d14c7571ba7b2511f13a3eaabec84a5 100644 (file)
@@ -16,13 +16,18 @@ var cmdInit = &base.Command{
        UsageLine: "go mod init [module]",
        Short:     "initialize new module in current directory",
        Long: `
-Init initializes and writes a new go.mod to the current directory,
-in effect creating a new module rooted at the current directory.
-The file go.mod must not already exist.
-If possible, init will guess the module path from import comments
-(see 'go help importpath') or from version control configuration.
-To override this guess, supply the module path as an argument.
-       `,
+Init initializes and writes a new go.mod file in the current directory, in
+effect creating a new module rooted at the current directory. The go.mod file
+must not already exist.
+
+Init accepts one optional argument, the module path for the new module. If the
+module path argument is omitted, init will attempt to infer the module path
+using import comments in .go files, vendoring tool configuration files (like
+Gopkg.lock), and the current directory (if in GOPATH).
+
+If a configuration file for a vendoring tool is present, init will attempt to
+import module requirements from it.
+`,
        Run: runInit,
 }