1
0
mirror of https://github.com/golang/go synced 2024-11-07 15:46:23 -07:00
go/src
Russ Cox 6121987a10 cmd/go: split go mod into multiple subcommands
The current "go mod" command does too many things.
The design is unclear.

It looks like "everything you might want to do with modules"
which causes people to think all module operations go through
"go mod", which is the opposite of the seamless integration we're
going for. In particular too many people think "go mod -require"
and "go get" are the same.

It does make sense to put the module-specific functionality
under "go mod", but not as flags. Instead, split "go mod" into
multiple subcommands:

	go mod edit   # old go mod -require ...
	go mod fix    # old go mod -fix
	go mod graph  # old go mod -graph
	go mod init   # old go mod -init
	go mod tidy   # old go mod -sync
	go mod vendor # old go mod -vendor
	go mod verify # old go mod -verify

Splitting out the individual commands makes both the docs
and the implementations dramatically easier to read.
It simplifies the command lines
(go mod -init -module m is now 'go mod init m')
and allows command-specific flags.

We've avoided subcommands in the go command to date, and we
should continue to avoid adding them unless it really makes
the experience significantly better. In this case, it does.

Creating subcommands required some changes in the core
command-parsing and help logic to generalize from one
level to multiple levels.

As part of having "go mod init" be a separate command,
this CL changes the failure behavior during module initialization
to be delayed until modules are actually needed.
Initialization can still happen early, but the base.Fatalf
is delayed until something needs to use modules.
This fixes a bunch of commands like 'go env' that were
unhelpfully failing with GO111MODULE=on when not in a
module directory.

Fixes #26432.
Fixes #26581.
Fixes #26596.
Fixes #26639.

Change-Id: I868db0babe8c288e8af684b29d4a5ae4825d6407
Reviewed-on: https://go-review.googlesource.com/126655
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-08-01 00:35:17 +00:00
..
archive
bufio
builtin
bytes
cmd cmd/go: split go mod into multiple subcommands 2018-08-01 00:35:17 +00:00
compress
container
context
crypto crypto/x509: skip TestSystemRoots 2018-07-27 16:44:57 +00:00
database/sql
debug
encoding
errors
expvar
flag
fmt
go go/doc: do not treat methods as test functions 2018-07-31 16:11:48 +00:00
hash
html html: lazily populate Unescape tables 2018-07-31 22:10:54 +00:00
image
index/suffixarray
internal
io
log
math
mime
net net/http: revert CL 89275 (don't sniff Content-Type when nosniff set) 2018-07-31 17:29:58 +00:00
os
path path: present the correct error message in TestMatch 2018-07-29 19:18:48 +00:00
plugin
reflect
regexp
runtime syscall: improve NewCallback documentation and panic message 2018-07-27 17:42:58 +00:00
sort
strconv
strings
sync
syscall syscall: remove support for O_NONBLOCK and O_SYNC on js/wasm 2018-07-31 17:03:39 +00:00
testing
text
time
unicode
unsafe
vendor/golang_org/x
all.bash
all.bat
all.rc
androidtest.bash
bootstrap.bash
buildall.bash
clean.bash
clean.bat
clean.rc
cmp.bash
iostest.bash
make.bash
make.bat
Make.dist
make.rc
naclmake.bash
nacltest.bash
race.bash
race.bat
run.bash
run.bat
run.rc