answer/pkg/dir/dir.go

28 lines
445 B
Go
Raw Normal View History

2022-09-27 17:59:05 +08:00
package dir
import "os"
func CreatePathIsNotExist(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
// create directory
if err := os.MkdirAll(path, os.ModePerm); err != nil {
return false, err
} else {
return true, nil
}
}
return false, err
}
2022-10-12 11:14:20 +08:00
func CheckPathExist(path string) bool {
_, err := os.Stat(path)
if err == nil {
return true
}
return false
}