answer/pkg/dir/dir.go

18 lines
313 B
Go
Raw Normal View History

2022-09-27 17:59:05 +08:00
package dir
import "os"
func CreateDirIfNotExist(path string) error {
return os.MkdirAll(path, os.ModePerm)
2022-09-27 17:59:05 +08:00
}
2022-10-12 11:14:20 +08:00
func CheckDirExist(path string) bool {
f, err := os.Stat(path)
return err == nil && f.IsDir()
}
func CheckFileExist(path string) bool {
f, err := os.Stat(path)
return err == nil && !f.IsDir()
2022-10-12 11:14:20 +08:00
}