From 8c92c9b5f1ba4282e2d4444e69e369aa8b9f2415 Mon Sep 17 00:00:00 2001 From: Vee Zhang Date: Wed, 16 Mar 2022 19:32:57 +0800 Subject: [PATCH] fix --- server/config/example-config.yaml | 2 +- server/pkg/webserver/base/scheme.go | 2 +- server/pkg/webserver/controller/files.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/config/example-config.yaml b/server/config/example-config.yaml index 00e2c311..218b5d5e 100644 --- a/server/config/example-config.yaml +++ b/server/config/example-config.yaml @@ -4,4 +4,4 @@ web: # tasks_dir: # sqlitedb_file_path: # ip: -# port: 7001 (production env), defaut is 9000 (test env) \ No newline at end of file +# port: 7001 # (production env), defaut is 9000 (test env) \ No newline at end of file diff --git a/server/pkg/webserver/base/scheme.go b/server/pkg/webserver/base/scheme.go index c5c56021..fe03dc19 100644 --- a/server/pkg/webserver/base/scheme.go +++ b/server/pkg/webserver/base/scheme.go @@ -37,7 +37,7 @@ func WrapHandler(handler Handler) iris.Handler { result := handler(ctx) ctx.StatusCode(iris.StatusOK) if result != nil { - ctx.JSON(&result) + _, _ = ctx.JSON(&result) } } } diff --git a/server/pkg/webserver/controller/files.go b/server/pkg/webserver/controller/files.go index cd0c00be..5b047b0d 100644 --- a/server/pkg/webserver/controller/files.go +++ b/server/pkg/webserver/controller/files.go @@ -160,6 +160,7 @@ func changeFileCharset2UTF8(filePath string, charSet string) error { zap.L().Warn("open file fail", zap.Error(err)) return err } + defer file.Close() reader := bufio.NewReader(file) decoder := mahonia.NewDecoder(charSet) decodeReader := decoder.NewReader(reader) @@ -168,12 +169,11 @@ func changeFileCharset2UTF8(filePath string, charSet string) error { if err != nil { return err } + defer fileUTF8.Close() writer := bufio.NewWriter(fileUTF8) if _, err = writer.ReadFrom(decodeReader); err != nil { return err } - file.Close() - fileUTF8.Close() if err = os.Rename(fileUTF8Path, filePath); err != nil { return err }