refactor: format code with interface, Close #22

This commit is contained in:
ᴍᴏᴏɴD4ʀᴋ
2020-08-01 02:36:44 +08:00
parent 5936e17e26
commit 2b2cc13cff
9 changed files with 637 additions and 703 deletions
+14 -2
View File
@@ -33,6 +33,17 @@ func CopyDB(src, dst string) error {
return err
}
func GetItemPath(profilePath, file string) (string, error) {
p, err := filepath.Glob(profilePath + file)
if err != nil {
return "", err
}
if len(p) > 0 {
return p[0], nil
}
return "", fmt.Errorf("find %s failed", file)
}
func IntToBool(a int) bool {
switch a {
case 0, -1:
@@ -87,8 +98,9 @@ func FormatFileName(dir, browser, filename, format string) string {
return p
}
func MakeDir(dirName string) {
func MakeDir(dirName string) error {
if _, err := os.Stat(dirName); os.IsNotExist(err) {
err = os.Mkdir(dirName, 0700)
return os.Mkdir(dirName, 0700)
}
return nil
}