]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: move module cache from $GOPATH/src/mod to $GOPATH/pkg/mod
authorRuss Cox <rsc@golang.org>
Mon, 30 Jul 2018 18:58:45 +0000 (14:58 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 1 Aug 2018 00:35:26 +0000 (00:35 +0000)
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: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Rob Pike <r@golang.org>
18 files changed:
src/cmd/go/alldocs.go
src/cmd/go/internal/clean/clean.go
src/cmd/go/internal/help/helpdoc.go
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/modconv/convert_test.go
src/cmd/go/internal/modfetch/cache.go
src/cmd/go/internal/modfetch/fetch.go
src/cmd/go/internal/modfetch/proxy.go
src/cmd/go/internal/modload/help.go
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/modload/query_test.go
src/cmd/go/testdata/addmod.go
src/cmd/go/testdata/script/mod_file_proxy.txt
src/cmd/go/testdata/script/mod_import_mod.txt
src/cmd/go/testdata/script/mod_list.txt
src/cmd/go/testdata/script/mod_list_dir.txt
src/cmd/go/testdata/script/mod_multirepo.txt
src/cmd/go/testdata/script/mod_verify.txt

index 242e00fbe822ae02a1e936207db1abeef9c74d5d..d6eebab3bf6cb78d09dc97825154807371c4b6e7 100644 (file)
 //             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.
 //     -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,
 //         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
 // 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
 // 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.
 //
 // 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.
 //
 // 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.
 // 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
 // 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,
 //             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.
 // 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
 // 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
 //
 // 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.
 //
 // 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.
 //
 // 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
 // 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
 //
 // 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.
 //
index d431385e9d6687c1c6690f3314e250a2a9bda7c7..d023592eedceac42b605ce11c5fe3304866e65b1 100644 (file)
@@ -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)
                }
        }
index 179812083a8ee237e5d19459d1973ad5a243225f..aff4ce12f6c9ae05db4ff1ef24b0c267761a853e 100644 (file)
@@ -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
index b112a4fb9d3bb8ee4647dce28270484520b56db6..1b21b632b87cc9713f77c355cf40a6051fd384e8 100644 (file)
@@ -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.
index 72baa7e3020eb02d4281b536e6f22b758eff35ca..f430380871aa1dba63e0e9ea314fc1f080db88df 100644 (file)
@@ -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()
index e0132f86735182a995b80b480f54f76034d5fc92..b801f6485c94aeefe0d85054c81807c5d16be2da 100644 (file)
@@ -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
        }
index 375c3f1478e79ec91f9c7c79aa47cf3447775cbd..b4944af8c2fe0c319f10ed2acacfce655c763a45 100644 (file)
@@ -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 ""
        }
index ce17ed2311b61b61131fd50fbcf5d858625116f2..693eb18b49be85db50b8a2797ce72b0944f249a0 100644 (file)
@@ -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.
 `,
index e924ec6486f74f45c2d96f29d60911d161c83d3e..64c70b7d7b3b61ba9463e50c62d723dfcb880930 100644 (file)
@@ -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
index a553854e0e1c2631de17b1a60a555f02b0fdc18f..8ce0c32fd5f67922c84629729378e8d2a5246e2e 100644 (file)
@@ -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
index 8f8df52269c643bd6b98d43dea96050974b6b841..7f3ffabef742035cf03634bf58d452c1d5420df0 100644 (file)
@@ -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()
 }
index 16dca0e8420efad7e630bebe3fe23273fa6c9c65..19850af0f37b29b22186c80a25d9bce6f7f696d1 100644 (file)
@@ -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
index 65b96f1a6ea3528d79cf42b4e64851e260e2c714..8de6d7dbb88ba514a08590a2845f39e81c5979b3 100644 (file)
@@ -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
index 46f45c7109e9213e3593434efb4f54e9172a9db0..b035e3dec22befb36e35d6db6b5c78d5a84c17da 100644 (file)
@@ -1,4 +1,4 @@
-# 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'
index bdf90074ab5e381ca3c55ba18ad1a68bf6c4da5a..c9797ea8364e42243c059cb47f46cfbfc8a4f0ac 100644 (file)
@@ -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
index 9b3ee14d1bbf0e865ee200936d85f4a7732c8c10..29cde71fb8db5b716d6572e13ae008e4460a3960 100644 (file)
@@ -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 --
index 74d952cca044020c676c0bd36c63f770037fd390..7f977e80f6e26060bc989c519ff044cde7ef8eee 100644 (file)
@@ -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
index 18bd94c42243a7ad983ac6e385b678479d019aac..50c9b4a43751aafacfc50a56e392fea0ae9f7454 100644 (file)
@@ -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