bbgo_origin/pkg/util/dir.go

24 lines
283 B
Go
Raw Normal View History

2022-05-17 10:23:09 +00:00
package util
import (
"fmt"
"os"
)
func SafeMkdirAll(p string) error {
st, err := os.Stat(p)
if err == nil {
if !st.IsDir() {
return fmt.Errorf("path %s is not a directory", p)
}
return nil
}
if os.IsNotExist(err) {
return os.MkdirAll(p, 0755)
}
return nil
}