Commit b8f42d74 authored by Russ Cox's avatar Russ Cox

cmd/go: move module cache from $GOPATH/src/mod to $GOPATH/pkg/mod

Using $GOPATH/src/mod confuses too many tools.
$GOPATH/pkg/mod seems better for now.
It's also next to dep's cache, $GOPATH/pkg/dep.
If we do eliminate GOPATH/pkg for holding .a files (#4719)
then we could still keep it around for pkg/mod.
(Or we could move the module cache again then.)

Fixes #26401.
Fixes #26635.

Change-Id: I18f7da216ed9f490eded3c00d837fb086ae5b6a4
Reviewed-on: https://go-review.googlesource.com/126755
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
Reviewed-by: 's avatarRob Pike <r@golang.org>
parent 27e546be
......@@ -130,8 +130,6 @@
// arguments to pass on each gccgo compiler/linker invocation.
// -gcflags '[pattern=]arg list'
// arguments to pass on each go tool compile invocation.
// -getmode mode
// module download mode to use. See 'go help modules' for more.
// -installsuffix suffix
// a suffix to use in the name of the package installation directory,
// in order to keep output separate from default builds.
......@@ -144,6 +142,9 @@
// -linkshared
// link against shared libraries previously created with
// -buildmode=shared.
// -mod mode
// module download mode to use: readonly, release, or vendor.
// See 'go help modules' for more.
// -pkgdir dir
// install and load all packages from dir instead of the usual locations.
// For example, when building with a non-standard configuration,
......@@ -641,20 +642,21 @@
// Module *Module // info about package's containing module, if any (can be nil)
//
// // Source files
// GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
// CgoFiles []string // .go sources files that import "C"
// IgnoredGoFiles []string // .go sources ignored due to build constraints
// CFiles []string // .c source files
// CXXFiles []string // .cc, .cxx and .cpp source files
// MFiles []string // .m source files
// HFiles []string // .h, .hh, .hpp and .hxx source files
// FFiles []string // .f, .F, .for and .f90 Fortran source files
// SFiles []string // .s source files
// SwigFiles []string // .swig files
// SwigCXXFiles []string // .swigcxx files
// SysoFiles []string // .syso object files to add to archive
// TestGoFiles []string // _test.go files in package
// XTestGoFiles []string // _test.go files outside package
// GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
// CgoFiles []string // .go source files that import "C"
// CompiledGoFiles []string // .go files presented to compiler (when using -compiled)
// IgnoredGoFiles []string // .go source files ignored due to build constraints
// CFiles []string // .c source files
// CXXFiles []string // .cc, .cxx and .cpp source files
// MFiles []string // .m source files
// HFiles []string // .h, .hh, .hpp and .hxx source files
// FFiles []string // .f, .F, .for and .f90 Fortran source files
// SFiles []string // .s source files
// SwigFiles []string // .swig files
// SwigCXXFiles []string // .swigcxx files
// SysoFiles []string // .syso object files to add to archive
// TestGoFiles []string // _test.go files in package
// XTestGoFiles []string // _test.go files outside package
//
// // Cgo directives
// CgoCFLAGS []string // cgo: flags for C compiler
......@@ -717,9 +719,10 @@
// The -json flag causes the package data to be printed in JSON format
// instead of using the template format.
//
// The -cgo flag causes list to set CgoFiles not to the original *.go files
// importing "C" but instead to the translated files generated by the cgo
// command.
// The -compiled flag causes list to set CompiledGoFiles to the Go source
// files presented to the compiler. Typically this means that it repeats
// the files listed in GoFiles and then also adds the Go code generated
// by processing CgoFiles and SwigFiles.
//
// The -deps flag causes list to iterate over not just the named packages
// but also all their dependencies. It visits them in a depth-first post-order
......@@ -740,6 +743,9 @@
// The -export flag causes list to set the Export field to the name of a
// file containing up-to-date export information for the given package.
//
// The -find flag causes list to identify the named packages but not
// resolve their dependencies: the Imports and Deps lists will be empty.
//
// The -test flag causes list to report not only the named packages
// but also their test binaries (for packages with tests), to convey to
// source code analysis tools exactly how test binaries are constructed.
......@@ -759,8 +765,8 @@
//
// By default, the lists GoFiles, CgoFiles, and so on hold names of files in Dir
// (that is, paths relative to Dir, not absolute paths).
// The extra entries added by the -cgo and -test flags are absolute paths
// referring to cached copies of generated Go source files.
// The generated files added when using the -compiled and -test flags
// are absolute paths referring to cached copies of generated Go source files.
// Although they are Go source files, the paths may not end in ".go".
//
// The -m flag causes list to list modules instead of packages.
......@@ -896,8 +902,6 @@
//
// The -module flag changes the module's path (the go.mod file's module line).
//
// The -go flag changes the minimum required version of Go listed in go.mod.
//
// The -require=path@version and -droprequire=path flags
// add and drop a requirement on the given module path and version.
// Note that -require overrides any existing requirements on path.
......@@ -910,12 +914,12 @@
// add and drop an exclusion for the given module path and version.
// Note that -exclude=path@version is a no-op if that exclusion already exists.
//
// The -replace=old@v=new@w and -dropreplace=old@v flags
// The -replace=old[@v]=new[@v] and -dropreplace=old[@v] flags
// add and drop a replacement of the given module path and version pair.
// If the @v in old@v is omitted, the replacement applies to all versions
// with the old module path. If the @v in new@v is omitted, the
// new path should be a directory on the local system, not a module path.
// Note that -replace overrides any existing replacements for old@v.
// with the old module path. If the @v in new@v is omitted, the new path
// should be a local module root directory, not a module path.
// Note that -replace overrides any existing replacements for old[@v].
//
// The -require, -droprequire, -exclude, -dropexclude, -replace,
// and -dropreplace editing flags may be repeated, and the changes
......@@ -989,10 +993,12 @@
// perhaps D v1.2.4 or D v1.3.0.
//
// Finally, fix removes redundant or misleading requirements.
// For example, if A v1.0.0 itself requires B v1.2.0 and C v1.0.0,
// then go.mod's requirement of B v1.0.0 is misleading (superseded
// by B's need for v1.2.0), and its requirement of C v1.0.0 is redundant
// (implied by B's need for the same version), so both will be removed.
// For example, if A v1.0.0 itself requires B v1.2.0 and C v1.0.0, then go.mod's
// requirement of B v1.0.0 is misleading (superseded by A's need for v1.2.0),
// and its requirement of C v1.0.0 is redundant (implied by A's need for the
// same version), so both will be removed. If module M contains packages
// that directly import packages from B or C, then the requirements will be
// kept but updated to the actual versions being used.
//
// Although fix runs the fix-up operation in isolation, the fix-up also
// runs automatically any time a go command uses the module graph,
......@@ -1396,8 +1402,9 @@
// information for reuse in future builds.
// GOFLAGS
// A space-separated list of -flag=value settings to apply
// to go commands by default (when the given flag is known by
// the current command).
// to go commands by default, when the given flag is known by
// the current command. Flags listed on the command-line
// are applied after this list and therefore override it.
// GOOS
// The operating system for which to compile code.
// Examples are linux, darwin, windows, netbsd.
......@@ -1611,7 +1618,7 @@
// GOPATH and Modules
//
// When using modules, GOPATH is no longer used for resolving imports.
// However, it is still used to store downloaded source code (in GOPATH/src/mod)
// However, it is still used to store downloaded source code (in GOPATH/pkg/mod)
// and compiled commands (in GOPATH/bin).
//
// Internal Directories
......@@ -1700,11 +1707,14 @@
// Module proxy protocol
//
// The go command by default downloads modules from version control systems
// directly, just as 'go get' always has. If the GOPROXY environment variable
// is set to the URL of a module proxy, the go command will instead fetch
// all modules from that proxy. No matter the source of the modules, downloaded
// modules must match existing entries in go.sum (see 'go help modules' for
// discussion of verification).
// directly, just as 'go get' always has. The GOPROXY environment variable allows
// further control over the download source. GOPROXY being unset, the empty string,
// or the string "direct" corresponds to the default direct connection to version
// control systems. Setting GOPROXY to "off" disallows downloading modules from
// any source. Otherwise, if GOPROXY is expected to be the URL of a module proxy,
// in which case the go command will fetch all modules from that proxy.
// No matter the source of the modules, downloaded modules must match existing
// entries in go.sum (see 'go help modules' for discussion of verification).
//
// A Go module proxy is any web server that can respond to GET requests for
// URLs of a specified form. The requests have no query parameters, so even
......@@ -1749,10 +1759,10 @@
//
// Even when downloading directly from version control systems,
// the go command synthesizes explicit info, mod, and zip files
// and stores them in its local cache, $GOPATH/src/mod/cache/download,
// and stores them in its local cache, $GOPATH/pkg/mod/cache/download,
// the same as if it had downloaded them directly from a proxy.
// The cache layout is the same as the proxy URL space, so
// serving $GOPATH/src/mod/cache/download at (or copying it to)
// serving $GOPATH/pkg/mod/cache/download at (or copying it to)
// https://example.com/proxy would let other users access those
// cached module versions with GOPROXY=https://example.com/proxy.
//
......@@ -1953,12 +1963,12 @@
// Modules replace the old GOPATH-based approach to specifying
// which source files are used in a given build.
//
// Experimental module support
// Preliminary module support
//
// Go 1.11 includes experimental support for Go modules,
// Go 1.11 includes preliminary support for Go modules,
// including a new module-aware 'go get' command.
// We intend to keep revising this support, while preserving compatibility,
// until it can be declared official (no longer experimental),
// until it can be declared official (no longer preliminary),
// and then at a later point we may remove support for work
// in GOPATH and the old 'go get' command.
//
......@@ -1983,7 +1993,7 @@
// containing a go.mod file.
//
// In module-aware mode, GOPATH no longer defines the meaning of imports
// during a build, but it still stores downloaded dependencies (in GOPATH/src/mod)
// during a build, but it still stores downloaded dependencies (in GOPATH/pkg/mod)
// and installed commands (in GOPATH/bin, unless GOBIN is set).
//
// Defining a module
......@@ -2106,6 +2116,15 @@
// The 'go mod' command provides other functionality for use in maintaining
// and understanding modules and go.mod files. See 'go help mod'.
//
// The -mod build flag provides additional control over updating and use of go.mod.
// If invoked with -mod=readonly, the go command disables its automatic updates
// of go.mod as described above and fails if any changes are needed. This setting
// is most useful to check that go.mod does not need any updates, such as in a
// continuous integration and testing system.
// If invoked with -mod=vendor, the go command assumes that the vendor
// directory holds the correct copies of dependencies and ignores
// the dependency descriptions in go.mod.
//
// Pseudo-versions
//
// The go.mod file and the go command more generally use semantic versions as
......@@ -2296,7 +2315,7 @@
//
// To build using the main module's top-level vendor directory to satisfy
// dependencies (disabling use of the usual network sources and local
// caches), use 'go build -getmode=vendor'. Note that only the main module's
// caches), use 'go build -mod=vendor'. Note that only the main module's
// top-level vendor directory is used; vendor directories in other locations
// are still ignored.
//
......
......@@ -153,10 +153,10 @@ func runClean(cmd *base.Command, args []string) {
}
if cleanModcache {
if modfetch.SrcMod == "" {
if modfetch.PkgMod == "" {
base.Fatalf("go clean -modcache: no module cache")
}
if err := removeAll(modfetch.SrcMod); err != nil {
if err := removeAll(modfetch.PkgMod); err != nil {
base.Errorf("go clean -modcache: %v", err)
}
}
......
......@@ -377,7 +377,7 @@ See https://golang.org/doc/code.html for an example.
GOPATH and Modules
When using modules, GOPATH is no longer used for resolving imports.
However, it is still used to store downloaded source code (in GOPATH/src/mod)
However, it is still used to store downloaded source code (in GOPATH/pkg/mod)
and compiled commands (in GOPATH/bin).
Internal Directories
......
......@@ -434,7 +434,7 @@ func LoadImport(path, srcDir string, parent *Package, stk *ImportStack, importPo
if strings.HasPrefix(path, "mod/") {
// Paths beginning with "mod/" might accidentally
// look in the module cache directory tree in $GOPATH/src/mod/.
// look in the module cache directory tree in $GOPATH/pkg/mod/.
// This prefix is owned by the Go core for possible use in the
// standard library (since it does not begin with a domain name),
// so it's OK to disallow entirely.
......
......@@ -39,7 +39,7 @@ func testMain(m *testing.M) int {
log.Fatal(err)
}
defer os.RemoveAll(dir)
modfetch.SrcMod = filepath.Join(dir, "src/mod")
modfetch.PkgMod = filepath.Join(dir, "pkg/mod")
codehost.WorkRoot = filepath.Join(dir, "codework")
return m.Run()
......
......@@ -22,17 +22,17 @@ import (
var QuietLookup bool // do not print about lookups
var SrcMod string // $GOPATH/src/mod; set by package modload
var PkgMod string // $GOPATH/pkg/mod; set by package modload
func cacheDir(path string) (string, error) {
if SrcMod == "" {
return "", fmt.Errorf("internal error: modfetch.SrcMod not set")
if PkgMod == "" {
return "", fmt.Errorf("internal error: modfetch.PkgMod not set")
}
enc, err := module.EncodePath(path)
if err != nil {
return "", err
}
return filepath.Join(SrcMod, "cache/download", enc, "/@v"), nil
return filepath.Join(PkgMod, "cache/download", enc, "/@v"), nil
}
func CachePath(m module.Version, suffix string) (string, error) {
......@@ -54,8 +54,8 @@ func CachePath(m module.Version, suffix string) (string, error) {
}
func DownloadDir(m module.Version) (string, error) {
if SrcMod == "" {
return "", fmt.Errorf("internal error: modfetch.SrcMod not set")
if PkgMod == "" {
return "", fmt.Errorf("internal error: modfetch.PkgMod not set")
}
enc, err := module.EncodePath(m.Path)
if err != nil {
......@@ -71,7 +71,7 @@ func DownloadDir(m module.Version) (string, error) {
if err != nil {
return "", err
}
return filepath.Join(SrcMod, enc+"@"+encVer), nil
return filepath.Join(PkgMod, enc+"@"+encVer), nil
}
// A cachingRepo is a cache around an underlying Repo,
......@@ -287,7 +287,7 @@ func readDiskStat(path, rev string) (file string, info *RevInfo, err error) {
// just to find out about a commit we already know about
// (and have cached under its pseudo-version).
func readDiskStatByHash(path, rev string) (file string, info *RevInfo, err error) {
if SrcMod == "" {
if PkgMod == "" {
// Do not download to current directory.
return "", nil, errNotCached
}
......
......@@ -28,9 +28,9 @@ var downloadCache par.Cache
// local download cache and returns the name of the directory
// corresponding to the root of the module's file tree.
func Download(mod module.Version) (dir string, err error) {
if SrcMod == "" {
if PkgMod == "" {
// Do not download to current directory.
return "", fmt.Errorf("missing modfetch.SrcMod")
return "", fmt.Errorf("missing modfetch.PkgMod")
}
// The par.Cache here avoids duplicate work but also
......@@ -53,7 +53,7 @@ func Download(mod module.Version) (dir string, err error) {
if _, err := os.Stat(zipfile); err == nil {
// Use it.
// This should only happen if the mod/cache directory is preinitialized
// or if src/mod/path was removed but not src/mod/cache/download.
// or if pkg/mod/path was removed but not pkg/mod/cache/download.
fmt.Fprintf(os.Stderr, "go: extracting %s %s\n", mod.Path, mod.Version)
} else {
if err := os.MkdirAll(filepath.Dir(zipfile), 0777); err != nil {
......@@ -200,7 +200,7 @@ func readGoSum(file string, data []byte) {
// checkSum checks the given module's checksum.
func checkSum(mod module.Version) {
if SrcMod == "" {
if PkgMod == "" {
// Do not use current directory.
return
}
......@@ -264,7 +264,7 @@ func checkOneSum(mod module.Version, h string) {
// Sum returns the checksum for the downloaded copy of the given module,
// if present in the download cache.
func Sum(mod module.Version) string {
if SrcMod == "" {
if PkgMod == "" {
// Do not use current directory.
return ""
}
......
......@@ -77,10 +77,10 @@ archive.
Even when downloading directly from version control systems,
the go command synthesizes explicit info, mod, and zip files
and stores them in its local cache, $GOPATH/src/mod/cache/download,
and stores them in its local cache, $GOPATH/pkg/mod/cache/download,
the same as if it had downloaded them directly from a proxy.
The cache layout is the same as the proxy URL space, so
serving $GOPATH/src/mod/cache/download at (or copying it to)
serving $GOPATH/pkg/mod/cache/download at (or copying it to)
https://example.com/proxy would let other users access those
cached module versions with GOPROXY=https://example.com/proxy.
`,
......
......@@ -50,7 +50,7 @@ GOPATH/src and itself contains a go.mod file or is below a directory
containing a go.mod file.
In module-aware mode, GOPATH no longer defines the meaning of imports
during a build, but it still stores downloaded dependencies (in GOPATH/src/mod)
during a build, but it still stores downloaded dependencies (in GOPATH/pkg/mod)
and installed commands (in GOPATH/bin, unless GOBIN is set).
Defining a module
......
......@@ -170,9 +170,9 @@ func Init() {
func init() {
load.ModInit = Init
// Set modfetch.SrcMod unconditionally, so that go clean -modcache can run even without modules enabled.
// Set modfetch.PkgMod unconditionally, so that go clean -modcache can run even without modules enabled.
if list := filepath.SplitList(cfg.BuildContext.GOPATH); len(list) > 0 && list[0] != "" {
modfetch.SrcMod = filepath.Join(list[0], "src/mod")
modfetch.PkgMod = filepath.Join(list[0], "pkg/mod")
}
}
......@@ -233,17 +233,17 @@ func InitMod() {
base.Fatalf("$GOPATH/go.mod exists but should not")
}
srcV := filepath.Join(list[0], "src/v")
srcMod := filepath.Join(list[0], "src/mod")
infoV, errV := os.Stat(srcV)
_, errMod := os.Stat(srcMod)
if errV == nil && infoV.IsDir() && errMod != nil && os.IsNotExist(errMod) {
os.Rename(srcV, srcMod)
oldSrcMod := filepath.Join(list[0], "src/mod")
pkgMod := filepath.Join(list[0], "pkg/mod")
infoOld, errOld := os.Stat(oldSrcMod)
_, errMod := os.Stat(pkgMod)
if errOld == nil && infoOld.IsDir() && errMod != nil && os.IsNotExist(errMod) {
os.Rename(oldSrcMod, pkgMod)
}
modfetch.SrcMod = srcMod
modfetch.PkgMod = pkgMod
modfetch.GoSumFile = filepath.Join(ModRoot, "go.sum")
codehost.WorkRoot = filepath.Join(srcMod, "cache/vcs")
codehost.WorkRoot = filepath.Join(pkgMod, "cache/vcs")
if CmdModInit {
// Running go mod init: do legacy module conversion
......
......@@ -29,7 +29,7 @@ func testMain(m *testing.M) int {
log.Fatal(err)
}
defer os.RemoveAll(dir)
modfetch.SrcMod = filepath.Join(dir, "src/mod")
modfetch.PkgMod = filepath.Join(dir, "pkg/mod")
codehost.WorkRoot = filepath.Join(dir, "codework")
return m.Run()
}
......
......@@ -97,13 +97,13 @@ func main() {
continue
}
path, vers, dir := f[0], f[1], f[2]
mod, err := ioutil.ReadFile(filepath.Join(gopath, "src/mod/cache/download", path, "@v", vers+".mod"))
mod, err := ioutil.ReadFile(filepath.Join(gopath, "pkg/mod/cache/download", path, "@v", vers+".mod"))
if err != nil {
log.Printf("%s: %v", arg, err)
exitCode = 1
continue
}
info, err := ioutil.ReadFile(filepath.Join(gopath, "src/mod/cache/download", path, "@v", vers+".info"))
info, err := ioutil.ReadFile(filepath.Join(gopath, "pkg/mod/cache/download", path, "@v", vers+".info"))
if err != nil {
log.Printf("%s: %v", arg, err)
exitCode = 1
......
......@@ -6,16 +6,16 @@ go mod edit -fmt
go list -mod=readonly
env GOPROXY=file:///nonexist
go list
grep v1.5.1 $GOPATH/src/mod/cache/download/rsc.io/quote/@v/list
grep v1.5.1 $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/list
# Use download cache as file:/// proxy.
[windows] stop # TODO: file://$WORK puts backslashes in the URL
env GOPATH=$WORK/gopath2
env GOPROXY=file:///nonexist
! go list
env GOPROXY=file://$WORK/gopath1/src/mod/cache/download
env GOPROXY=file://$WORK/gopath1/pkg/mod/cache/download
go list
grep v1.5.1 $GOPATH/src/mod/cache/download/rsc.io/quote/@v/list
grep v1.5.1 $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/list
-- $WORK/x/go.mod --
module x
......
# Test that GOPATH/src/mod is excluded
# Test that GOPATH/pkg/mod is excluded
env GO111MODULE=off
! go list mod/foo
stderr 'disallowed import path'
......
......@@ -10,12 +10,12 @@ go list -f '{{.Dir}}' rsc.io/quote
stdout '.*mod[\\/]rsc.io[\\/]quote@v1.5.2$'
# downloaded dependencies are read-only
exists -readonly $GOPATH/src/mod/rsc.io/quote@v1.5.2
exists -readonly $GOPATH/src/mod/rsc.io/quote@v1.5.2/buggy
exists -readonly $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
exists -readonly $GOPATH/pkg/mod/rsc.io/quote@v1.5.2/buggy
# go clean -modcache can delete read-only dependencies
go clean -modcache
! exists $GOPATH/src/mod/rsc.io/quote@v1.5.2
! exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
# list {{.Dir}} shows replaced directories
cp go.mod2 go.mod
......
......@@ -9,14 +9,14 @@ go list -f '{{.ImportPath}}' $GOROOT/src/math
stdout ^math$
go list -f '{{.ImportPath}}' .
stdout ^x$
go list -f '{{.ImportPath}}' $GOPATH/src/mod/rsc.io/quote@v1.5.2
go list -f '{{.ImportPath}}' $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
stdout '^rsc.io/quote$'
go list -f '{{.ImportPath}}' $GOPATH/src/mod/rsc.io/sampler@v1.3.0
go list -f '{{.ImportPath}}' $GOPATH/pkg/mod/rsc.io/sampler@v1.3.0
stdout '^rsc.io/sampler$'
go get rsc.io/sampler@v1.3.1
go list -f '{{.ImportPath}}' $GOPATH/src/mod/rsc.io/sampler@v1.3.1
go list -f '{{.ImportPath}}' $GOPATH/pkg/mod/rsc.io/sampler@v1.3.1
stdout '^rsc.io/sampler$'
! go list -f '{{.ImportPath}}' $GOPATH/src/mod/rsc.io/sampler@v1.3.0
! go list -f '{{.ImportPath}}' $GOPATH/pkg/mod/rsc.io/sampler@v1.3.0
stderr 'outside available modules'
-- go.mod --
......
......@@ -2,25 +2,25 @@ env GO111MODULE=on
# initial standalone module should use no downloaded modules
go list -deps -f {{.Dir}}
! stdout 'src[\\/]mod'
! stdout 'pkg[\\/]mod'
# v2 import should use a downloaded module
# both without an explicit go.mod entry ...
cp tmp/use_v2.go x.go
go list -deps -f {{.Dir}}
stdout 'src[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$'
stdout 'pkg[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$'
# ... and with one ...
cp tmp/use_v2.mod go.mod
go list -deps -f {{.Dir}}
stdout 'src[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$'
stdout 'pkg[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$'
# ... and even if there is a v2 module in a subdirectory.
mkdir v2
cp x.go v2/x.go
cp tmp/v2.mod v2/go.mod
go list -deps -f {{.Dir}}
stdout 'src[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$'
stdout 'pkg[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$'
-- go.mod --
module rsc.io/quote
......
......@@ -3,12 +3,12 @@ env GO111MODULE=on
# With good go.sum, verify succeeds by avoiding download.
cp go.sum.good go.sum
go mod verify
! exists $GOPATH/src/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
# With bad go.sum, verify succeeds by avoiding download.
cp go.sum.bad go.sum
go mod verify
! exists $GOPATH/src/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
# With bad go.sum, sync (which must download) fails.
# Even if the bad sum is in the old legacy go.modverify file.
......@@ -16,14 +16,14 @@ rm go.sum
cp go.sum.bad go.modverify
! go mod tidy
stderr 'checksum mismatch'
! exists $GOPATH/src/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
# With good go.sum, sync works (and moves go.modverify to go.sum).
rm go.sum
cp go.sum.good go.modverify
go mod tidy
exists $GOPATH/src/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
exists $GOPATH/src/mod/rsc.io/quote@v1.1.0/quote.go
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
exists $GOPATH/pkg/mod/rsc.io/quote@v1.1.0/quote.go
! exists go.modverify
# go.sum should have the new checksum for go.mod
......@@ -50,7 +50,7 @@ grep '^rsc.io/quote v1.1.0/go.mod ' go.sum
grep '^rsc.io/quote v1.1.0 ' go.sum
# sync should ignore missing ziphash; verify should not
rm $GOPATH/src/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash
rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash
go mod tidy
! go mod verify
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment