From d6cb101512057e7661d7f278dcd6ce1cadcfec94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=E1=B4=8F=E1=B4=8F=C9=B4D4=CA=80=E1=B4=8B?= Date: Fri, 29 Apr 2022 21:30:14 +0800 Subject: [PATCH] refactor: remove log from fileutil --- cmd/hack-browser-data/main.go | 1 + internal/utils/fileutil/filetutil.go | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/hack-browser-data/main.go b/cmd/hack-browser-data/main.go index dc9c345..d08a7fc 100644 --- a/cmd/hack-browser-data/main.go +++ b/cmd/hack-browser-data/main.go @@ -65,6 +65,7 @@ func Execute() { if err = fileutil.CompressDir(outputDir); err != nil { log.Error(err) } + log.Noticef("compress success") } return nil }, diff --git a/internal/utils/fileutil/filetutil.go b/internal/utils/fileutil/filetutil.go index b8c8b92..135385a 100644 --- a/internal/utils/fileutil/filetutil.go +++ b/internal/utils/fileutil/filetutil.go @@ -10,8 +10,6 @@ import ( "path/filepath" "strings" - "hack-browser-data/internal/log" - cp "github.com/otiai10/copy" ) @@ -72,7 +70,7 @@ func ParentBaseDir(p string) string { func CompressDir(dir string) error { files, err := ioutil.ReadDir(dir) if err != nil { - log.Error(err) + return err } var b = new(bytes.Buffer) zw := zip.NewWriter(b) @@ -91,7 +89,7 @@ func CompressDir(dir string) error { } err = os.Remove(fileName) if err != nil { - log.Error(err) + return err } } if err := zw.Close(); err != nil { @@ -106,6 +104,5 @@ func CompressDir(dir string) error { if err != nil { return err } - log.Noticef("compress success, zip filename is %s", filename) return nil }