mirror of
https://github.com/golang/go
synced 2024-11-22 08:34:40 -07:00
cmd/go: don't ignore error when 'go clean'
Fixes #4208. R=golang-dev, iant CC=golang-dev https://golang.org/cl/6635064
This commit is contained in:
parent
be2b95fe3a
commit
bf7d229eb8
@ -170,7 +170,9 @@ func clean(p *Package) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
os.RemoveAll(filepath.Join(p.Dir, name))
|
||||
if err := os.RemoveAll(filepath.Join(p.Dir, name)); err != nil {
|
||||
errorf("go clean: %v", err)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
@ -180,7 +182,7 @@ func clean(p *Package) {
|
||||
}
|
||||
|
||||
if cleanFile[name] || cleanExt[filepath.Ext(name)] || toRemove[name] {
|
||||
os.Remove(filepath.Join(p.Dir, name))
|
||||
removeFile(filepath.Join(p.Dir, name))
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,7 +191,7 @@ func clean(p *Package) {
|
||||
b.showcmd("", "rm -f %s", p.target)
|
||||
}
|
||||
if !cleanN {
|
||||
os.Remove(p.target)
|
||||
removeFile(p.target)
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +204,7 @@ func clean(p *Package) {
|
||||
b.showcmd("", "rm -f %s", target)
|
||||
}
|
||||
if !cleanN {
|
||||
os.Remove(target)
|
||||
removeFile(target)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,3 +215,11 @@ func clean(p *Package) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// removeFile tries to remove file f, if error other than file doesn't exist
|
||||
// occurs, it will report the error.
|
||||
func removeFile(f string) {
|
||||
if err := os.Remove(f); err != nil && !os.IsNotExist(err) {
|
||||
errorf("go clean: %v", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user