17 lines
366 B
Go
17 lines
366 B
Go
|
package sh
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
// Rm removes the given file or directory even if non-empty. It will not return
|
||
|
// an error if the target doesn't exist, only if the target cannot be removed.
|
||
|
func Rm(path string) error {
|
||
|
err := os.RemoveAll(path)
|
||
|
if err == nil || os.IsNotExist(err) {
|
||
|
return nil
|
||
|
}
|
||
|
return fmt.Errorf(`failed to remove %s: %v`, path, err)
|
||
|
}
|