rm -rf
(dirs ...string)
| 280 | |
| 281 | // rm -rf |
| 282 | func removeAll(dirs ...string) error { |
| 283 | for _, dir := range dirs { |
| 284 | files, err := filepath.Glob(dir) |
| 285 | if err != nil { |
| 286 | return err |
| 287 | } |
| 288 | for _, file := range files { |
| 289 | // Set any non-writeable files and dirs to writeable. This is necessary for os.RemoveAll to work on Windows. |
| 290 | filepath.Walk(file, func(path string, info os.FileInfo, err error) error { |
| 291 | if err != nil { |
| 292 | return err |
| 293 | } |
| 294 | if info.Mode()&0o700 != 0o700 { |
| 295 | os.Chmod(path, 0o777) |
| 296 | } |
| 297 | return nil |
| 298 | }) |
| 299 | os.RemoveAll(file) |
| 300 | } |
| 301 | } |
| 302 | return nil |
| 303 | } |
| 304 | |
| 305 | // Compare a number of directories. Returns nil if the contents are identical, |
| 306 | // otherwise an error describing the first found difference. |