site/vendor/github.com/magefile/mage/sh/helpers.go

17 lines
366 B
Go
Raw Normal View History

2017-12-13 18:43:58 +00:00
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)
}