From 995eba03d39ab4badf905ff3a99f5a254e5262c4 Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Wed, 31 Mar 2021 18:27:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=F0=9F=90=9B=20=EF=BC=9A=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DIsNotExistMkDir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/pkg/utils/file.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/pkg/utils/file.go b/sdk/pkg/utils/file.go index f6be68c7..f3ecf0fd 100644 --- a/sdk/pkg/utils/file.go +++ b/sdk/pkg/utils/file.go @@ -39,9 +39,10 @@ func CheckPermission(src string) bool { return os.IsPermission(err) } -// IsNotExistMkDir 如果不存在则新建文件夹 +// IsNotExistMkDir 检查文件夹是否存在 +// 如果不存在则新建文件夹 func IsNotExistMkDir(src string) error { - if exist := CheckExist(src); exist == false { + if exist := !CheckExist(src); exist == false { if err := MkDir(src); err != nil { return err } @@ -124,4 +125,4 @@ func GetType(p string) (string, error) { //var list = strings.Split(filetype, "/") //filetype = list[0] + "/" + ext return filetype, nil -} +} \ No newline at end of file From ea4bd4117d1383bae22e859810878a2f608f4aca Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Wed, 31 Mar 2021 18:44:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat=20=E2=9C=A8=EF=BC=9A=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/pkg/utils/file_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sdk/pkg/utils/file_test.go diff --git a/sdk/pkg/utils/file_test.go b/sdk/pkg/utils/file_test.go new file mode 100644 index 00000000..7efc3286 --- /dev/null +++ b/sdk/pkg/utils/file_test.go @@ -0,0 +1,15 @@ +package utils + +import ( + "testing" +) + +// TestIsNotExistMkDir 测试IsNotExistMkDir函数 +func TestIsNotExistMkDir(t *testing.T) { + err := IsNotExistMkDir("../../pkg/aaa") + if err != nil { + t.Error(err) + } else { + t.Log("done") + } +} \ No newline at end of file