mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 17:13:51 +00:00
24 lines
283 B
Go
24 lines
283 B
Go
|
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
|
||
|
}
|