github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/go/internal/clean/clean.go (about)

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package clean implements the “go clean” command.
     6  package clean
     7  
     8  import (
     9  	"github.com/shogo82148/std/cmd/go/internal/base"
    10  )
    11  
    12  var CmdClean = &base.Command{
    13  	UsageLine: "go clean [clean flags] [build flags] [packages]",
    14  	Short:     "remove object files and cached files",
    15  	Long: `
    16  Clean removes object files from package source directories.
    17  The go command builds most objects in a temporary directory,
    18  so go clean is mainly concerned with object files left by other
    19  tools or by manual invocations of go build.
    20  
    21  If a package argument is given or the -i or -r flag is set,
    22  clean removes the following files from each of the
    23  source directories corresponding to the import paths:
    24  
    25  	_obj/            old object directory, left from Makefiles
    26  	_test/           old test directory, left from Makefiles
    27  	_testmain.go     old gotest file, left from Makefiles
    28  	test.out         old test log, left from Makefiles
    29  	build.out        old test log, left from Makefiles
    30  	*.[568ao]        object files, left from Makefiles
    31  
    32  	DIR(.exe)        from go build
    33  	DIR.test(.exe)   from go test -c
    34  	MAINFILE(.exe)   from go build MAINFILE.go
    35  	*.so             from SWIG
    36  
    37  In the list, DIR represents the final path element of the
    38  directory, and MAINFILE is the base name of any Go source
    39  file in the directory that is not included when building
    40  the package.
    41  
    42  The -i flag causes clean to remove the corresponding installed
    43  archive or binary (what 'go install' would create).
    44  
    45  The -n flag causes clean to print the remove commands it would execute,
    46  but not run them.
    47  
    48  The -r flag causes clean to be applied recursively to all the
    49  dependencies of the packages named by the import paths.
    50  
    51  The -x flag causes clean to print remove commands as it executes them.
    52  
    53  The -cache flag causes clean to remove the entire go build cache.
    54  
    55  The -testcache flag causes clean to expire all test results in the
    56  go build cache.
    57  
    58  The -modcache flag causes clean to remove the entire module
    59  download cache, including unpacked source code of versioned
    60  dependencies.
    61  
    62  The -fuzzcache flag causes clean to remove files stored in the Go build
    63  cache for fuzz testing. The fuzzing engine caches files that expand
    64  code coverage, so removing them may make fuzzing less effective until
    65  new inputs are found that provide the same coverage. These files are
    66  distinct from those stored in testdata directory; clean does not remove
    67  those files.
    68  
    69  For more about build flags, see 'go help build'.
    70  
    71  For more about specifying packages, see 'go help packages'.
    72  	`,
    73  }