From a73b211ac3480d2538d5ca94cb043bc9ea987d95 Mon Sep 17 00:00:00 2001 From: Fufu Date: Mon, 19 Feb 2024 16:21:06 +0800 Subject: [PATCH] ci: golangci-lint --- common/init.go | 4 ++-- config/remote.go | 8 ++++---- stats/stats.go | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/common/init.go b/common/init.go index e982dec..27031ae 100644 --- a/common/init.go +++ b/common/init.go @@ -1,7 +1,7 @@ package common import ( - "fmt" + "errors" "github.com/fufuok/utils/myip" @@ -44,7 +44,7 @@ func (m *M) Start() error { // Runtime 重新加载配置时运行 func (m *M) Runtime() error { if err := loadLogger(); err != nil { - return fmt.Errorf("unable to reinitialize logger") + return errors.New("unable to reinitialize logger") } loadReq() return nil diff --git a/config/remote.go b/config/remote.go index 4fcf9c6..12128e4 100644 --- a/config/remote.go +++ b/config/remote.go @@ -1,6 +1,7 @@ package config import ( + "errors" "fmt" "os" "strconv" @@ -29,7 +30,7 @@ type DataSourceArgs struct { func GetDataSource(args any) error { params, ok := args.(DataSourceArgs) if !ok { - return fmt.Errorf("invalid data source configuration") + return errors.New("invalid data source configuration") } body, err := GetDataSourceBody(params) @@ -41,8 +42,7 @@ func GetDataSource(args any) error { md5Old := xhash.MustMD5Sum(params.Conf.Path) md5New := xhash.MD5Hex(body) if md5New != md5Old { - // #nosec G306 - if err = os.WriteFile(params.Conf.Path, []byte(body), 0644); err != nil { + if err = os.WriteFile(params.Conf.Path, []byte(body), 0600); err != nil { return err } } @@ -75,7 +75,7 @@ func GetDataSourceBody(params DataSourceArgs) (string, error) { body = strings.TrimSpace(body) if body == "" { - return "", fmt.Errorf("data source result is empty") + return "", errors.New("data source result is empty") } return body, nil } diff --git a/stats/stats.go b/stats/stats.go index cba9423..d80ffcc 100644 --- a/stats/stats.go +++ b/stats/stats.go @@ -37,7 +37,6 @@ func SYSStats() map[string]any { "NumCgoCall": utils.Comma(runtime.NumCgoCall()), "InternalIPv4": common.InternalIPv4, "ExternalIPv4": common.ExternalIPv4, - "HTTPS": config.Config().WebConf.ServerHttpsAddr != "", "JSON": json.Name, "GoPool": ants.Running(), }