]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: add go help cache
authorRuss Cox <rsc@golang.org>
Tue, 9 Jan 2018 21:31:12 +0000 (16:31 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 22 Jan 2018 16:51:09 +0000 (16:51 +0000)
Change-Id: I14eeda85f279d1082ea9f2ac590b848ac13b1daa
Reviewed-on: https://go-review.googlesource.com/87023
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/go/alldocs.go
src/cmd/go/internal/help/helpdoc.go
src/cmd/go/internal/test/test.go
src/cmd/go/main.go

index 48a414bf85af557b5b473826f0cfcd9e30a0d8b1..0dc72abbc83c8bf5b833fa3840de5ac6a2eaeed1 100644 (file)
 // Additional help topics:
 //
 //     c           calling between Go and C
-//     buildmode   description of build modes
+//     buildmode   build modes
+//     cache       build and test caching
 //     filetype    file types
 //     gopath      GOPATH environment variable
 //     environment environment variables
 //     importpath  import path syntax
-//     packages    description of package lists
-//     testflag    description of testing flags
-//     testfunc    description of testing functions
+//     packages    package lists
+//     testflag    testing flags
+//     testfunc    testing functions
 //
 // Use "go help [topic]" for more information about that topic.
 //
 // the C or C++ compiler, respectively, to use.
 //
 //
-// Description of build modes
+// Build modes
 //
 // The 'go build' and 'go install' commands take a -buildmode argument which
 // indicates which kind of object file is to be built. Currently supported values
 //             import, into a Go plugin. Packages not named main are ignored.
 //
 //
+// Build and test caching
+//
+// The go command caches build outputs for reuse in future builds.
+// The default location for cache data is a subdirectory named go-build
+// in the standard user cache directory for the current operating system.
+// Setting the GOCACHE environment variable overrides this default,
+// and running 'go env GOCACHE' prints the current cache directory.
+//
+// The go command periodically deletes cached data that has not been
+// used recently. Running 'go clean -cache' deletes all cached data.
+//
+// The build cache correctly accounts for changes to Go source files,
+// compilers, compiler options, and so on: cleaning the cache explicitly
+// should not be necessary in typical use. However, the build cache
+// does not detect changes to C libraries imported with cgo.
+// If you have made changes to the C libraries on your system, you
+// will need to clean the cache explicitly or else use the -a build flag
+// (see 'go help build') to force rebuilding of packages that
+// depend on the updated C libraries.
+//
+// The go command also caches successful package test results.
+// See 'go help test' for details. Running 'go clean -testcache' removes
+// all cached test results (but not cached build results).
+//
+// The GODEBUG environment variable can enable printing of debugging
+// information about the state of the cache:
+//
+// GODEBUG=gocacheverify=1 causes the go command to bypass the
+// use of any cache entries and instead rebuild everything and check
+// that the results match existing cache entries.
+//
+// GODEBUG=gocachehash=1 causes the go command to print the inputs
+// for all of the content hashes it uses to construct cache lookup keys.
+// The output is voluminous but can be useful for debugging the cache.
+//
+// GODEBUG=gocachetest=1 causes the go command to print details of its
+// decisions about whether to reuse a cached test result.
+//
+//
 // File types
 //
 // The go command examines the contents of a restricted set of files
 // See https://golang.org/s/go14customimport for details.
 //
 //
-// Description of package lists
+// Package lists
 //
 // Many commands apply to a set of packages:
 //
 // by the go tool, as are directories named "testdata".
 //
 //
-// Description of testing flags
+// Testing flags
 //
 // The 'go test' command takes both flags that apply to 'go test' itself
 // and flags that apply to the resulting test binary.
 // binary, instead of being interpreted as the package list.
 //
 //
-// Description of testing functions
+// Testing functions
 //
 // The 'go test' command expects to find test, benchmark, and example functions
 // in the "*_test.go" files corresponding to the package under test.
index 43144db593ab43b638f97171802a90a5a53988ab..4ebf206078942777109c63b14dbf7424848da4d6 100644 (file)
@@ -30,7 +30,7 @@ the C or C++ compiler, respectively, to use.
 
 var HelpPackages = &base.Command{
        UsageLine: "packages",
-       Short:     "description of package lists",
+       Short:     "package lists",
        Long: `
 Many commands apply to a set of packages:
 
@@ -583,7 +583,7 @@ command.
 
 var HelpBuildmode = &base.Command{
        UsageLine: "buildmode",
-       Short:     "description of build modes",
+       Short:     "build modes",
        Long: `
 The 'go build' and 'go install' commands take a -buildmode argument which
 indicates which kind of object file is to be built. Currently supported values
@@ -629,3 +629,45 @@ are:
                import, into a Go plugin. Packages not named main are ignored.
 `,
 }
+
+var HelpCache = &base.Command{
+       UsageLine: "cache",
+       Short:     "build and test caching",
+       Long: `
+The go command caches build outputs for reuse in future builds.
+The default location for cache data is a subdirectory named go-build
+in the standard user cache directory for the current operating system.
+Setting the GOCACHE environment variable overrides this default,
+and running 'go env GOCACHE' prints the current cache directory.
+
+The go command periodically deletes cached data that has not been
+used recently. Running 'go clean -cache' deletes all cached data.
+
+The build cache correctly accounts for changes to Go source files,
+compilers, compiler options, and so on: cleaning the cache explicitly
+should not be necessary in typical use. However, the build cache
+does not detect changes to C libraries imported with cgo.
+If you have made changes to the C libraries on your system, you
+will need to clean the cache explicitly or else use the -a build flag
+(see 'go help build') to force rebuilding of packages that
+depend on the updated C libraries.
+
+The go command also caches successful package test results.
+See 'go help test' for details. Running 'go clean -testcache' removes
+all cached test results (but not cached build results).
+
+The GODEBUG environment variable can enable printing of debugging
+information about the state of the cache:
+
+GODEBUG=gocacheverify=1 causes the go command to bypass the
+use of any cache entries and instead rebuild everything and check
+that the results match existing cache entries.
+
+GODEBUG=gocachehash=1 causes the go command to print the inputs
+for all of the content hashes it uses to construct cache lookup keys.
+The output is voluminous but can be useful for debugging the cache.
+
+GODEBUG=gocachetest=1 causes the go command to print details of its
+decisions about whether to reuse a cached test result.
+`,
+}
index 1936112c2ec5b43d076f16aea30c7e9656af6f2b..fa789a48b9bc41d762c169655a5c5e27c7574187 100644 (file)
@@ -176,7 +176,7 @@ func Usage() {
 
 var HelpTestflag = &base.Command{
        UsageLine: "testflag",
-       Short:     "description of testing flags",
+       Short:     "testing flags",
        Long: `
 The 'go test' command takes both flags that apply to 'go test' itself
 and flags that apply to the resulting test binary.
@@ -410,7 +410,7 @@ binary, instead of being interpreted as the package list.
 
 var HelpTestfunc = &base.Command{
        UsageLine: "testfunc",
-       Short:     "description of testing functions",
+       Short:     "testing functions",
        Long: `
 The 'go test' command expects to find test, benchmark, and example functions
 in the "*_test.go" files corresponding to the package under test.
index b7e4034152ab7e1220a8382d6d709823ec439594..497970b725c781f10bed58bd143525af25c61701 100644 (file)
@@ -56,6 +56,7 @@ func init() {
 
                help.HelpC,
                help.HelpBuildmode,
+               help.HelpCache,
                help.HelpFileType,
                help.HelpGopath,
                help.HelpEnvironment,