summaryrefslogtreecommitdiff
path: root/src/cmd/go/clean.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/go/clean.go')
-rw-r--r--src/cmd/go/clean.go41
1 files changed, 15 insertions, 26 deletions
diff --git a/src/cmd/go/clean.go b/src/cmd/go/clean.go
index 16687f72f..16054a5b5 100644
--- a/src/cmd/go/clean.go
+++ b/src/cmd/go/clean.go
@@ -13,7 +13,7 @@ import (
)
var cmdClean = &Command{
- UsageLine: "clean [-i] [-r] [-n] [-x] [packages]",
+ UsageLine: "clean [-i] [-r] [-n] [-x] [build flags] [packages]",
Short: "remove object files",
Long: `
Clean removes object files from package source directories.
@@ -52,23 +52,26 @@ dependencies of the packages named by the import paths.
The -x flag causes clean to print remove commands as it executes them.
+For more about build flags, see 'go help build'.
+
For more about specifying packages, see 'go help packages'.
`,
}
var cleanI bool // clean -i flag
-var cleanN bool // clean -n flag
var cleanR bool // clean -r flag
-var cleanX bool // clean -x flag
func init() {
// break init cycle
cmdClean.Run = runClean
cmdClean.Flag.BoolVar(&cleanI, "i", false, "")
- cmdClean.Flag.BoolVar(&cleanN, "n", false, "")
cmdClean.Flag.BoolVar(&cleanR, "r", false, "")
- cmdClean.Flag.BoolVar(&cleanX, "x", false, "")
+ // -n and -x are important enough to be
+ // mentioned explicitly in the docs but they
+ // are part of the build flags.
+
+ addBuildFlags(cmdClean)
}
func runClean(cmd *Command, args []string) {
@@ -153,7 +156,7 @@ func clean(p *Package) {
elem+".test.exe",
)
- // Remove a potental executable for each .go file in the directory that
+ // Remove a potential executable for each .go file in the directory that
// is not part of the directory's package.
for _, dir := range dirs {
name := dir.Name()
@@ -169,7 +172,7 @@ func clean(p *Package) {
}
}
- if cleanN || cleanX {
+ if buildN || buildX {
b.showcmd(p.Dir, "rm -f %s", strings.Join(allRemove, " "))
}
@@ -182,9 +185,9 @@ func clean(p *Package) {
if dir.IsDir() {
// TODO: Remove once Makefiles are forgotten.
if cleanDir[name] {
- if cleanN || cleanX {
+ if buildN || buildX {
b.showcmd(p.Dir, "rm -r %s", name)
- if cleanN {
+ if buildN {
continue
}
}
@@ -195,7 +198,7 @@ func clean(p *Package) {
continue
}
- if cleanN {
+ if buildN {
continue
}
@@ -205,28 +208,14 @@ func clean(p *Package) {
}
if cleanI && p.target != "" {
- if cleanN || cleanX {
+ if buildN || buildX {
b.showcmd("", "rm -f %s", p.target)
}
- if !cleanN {
+ if !buildN {
removeFile(p.target)
}
}
- if cleanI && p.usesSwig() {
- for _, f := range stringList(p.SwigFiles, p.SwigCXXFiles) {
- dir := p.swigDir(&buildContext)
- soname := p.swigSoname(f)
- target := filepath.Join(dir, soname)
- if cleanN || cleanX {
- b.showcmd("", "rm -f %s", target)
- }
- if !cleanN {
- removeFile(target)
- }
- }
- }
-
if cleanR {
for _, p1 := range p.imports {
clean(p1)