]> Cypherpunks repositories - gostls13.git/commit
cmd/go: refactor modload.InitMod
authorJay Conrod <jayconrod@google.com>
Thu, 22 Oct 2020 22:20:00 +0000 (18:20 -0400)
committerJay Conrod <jayconrod@google.com>
Fri, 23 Oct 2020 20:54:19 +0000 (20:54 +0000)
commitd05e89a8fd35bb543df6a29faea81a85565db92f
treee13704ef425d9faf2339becffb1eec0e30e643db
parentc8c3c29daa74f2d3e1a26f2e289ad3d2b9ba20dd
cmd/go: refactor modload.InitMod

InitMod is split into two functions. LoadModFile parses an existing
go.mod file and loads the build list (or checks vendor/modules.txt for
consistency in vendor mode). CreateModFile creates a new go.mod file,
possibly inferring the module path and importing a vendor
configuration file.

Some logic is moved from runInit to CreateModFile. init-specific logic
is removed from other functions.

This CL shouldn't cause substantial differences in behavior, though
some error messages are slightly different.

For #41712

Change-Id: Ia684945cfcf5beca30bbb81e7144fc246c4f27ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/264621
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/internal/list/list.go
src/cmd/go/internal/modcmd/download.go
src/cmd/go/internal/modcmd/init.go
src/cmd/go/internal/modload/buildlist.go
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/modload/load.go
src/cmd/go/testdata/script/mod_init_path.txt