add some unittests and bug fix

This commit is contained in:
hdt3213
2021-05-02 18:48:44 +08:00
parent 37779717e4
commit 9f3ac88b36
19 changed files with 256 additions and 146 deletions

View File

@@ -2,22 +2,9 @@ package files
import (
"fmt"
"io/ioutil"
"mime/multipart"
"os"
"path"
)
func GetSize(f multipart.File) (int, error) {
content, err := ioutil.ReadAll(f)
return len(content), err
}
func GetExt(fileName string) string {
return path.Ext(fileName)
}
func CheckNotExist(src string) bool {
_, err := os.Stat(src)
@@ -26,7 +13,6 @@ func CheckNotExist(src string) bool {
func CheckPermission(src string) bool {
_, err := os.Stat(src)
return os.IsPermission(err)
}
@@ -36,7 +22,6 @@ func IsNotExistMkDir(src string) error {
return err
}
}
return nil
}