• Russ Cox's avatar
    cmd/go: split go mod into multiple subcommands · 6121987a
    Russ Cox authored
    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: 's avatarBryan C. Mills <bcmills@google.com>
    6121987a
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
context Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
plugin Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
vendor/golang_org/x Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
cmp.bash Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
naclmake.bash Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...