From 4e7e255997a693253b84a295ba77763ec37f1ea9 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Mon, 16 May 2022 20:56:39 +0800 Subject: [PATCH] fix lint ci --- dtmsvr/api.go | 1 + dtmsvr/config/config.go | 5 +++-- dtmsvr/config/config_utils.go | 2 +- dtmsvr/entry/main.go | 2 +- main.go | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dtmsvr/api.go b/dtmsvr/api.go index d580d4b..831884a 100644 --- a/dtmsvr/api.go +++ b/dtmsvr/api.go @@ -15,6 +15,7 @@ import ( "github.com/dtm-labs/dtm/dtmsvr/storage" ) +// Version store the passin version for dtm server var Version = "" func svcSubmit(t *TransGlobal) interface{} { diff --git a/dtmsvr/config/config.go b/dtmsvr/config/config.go index 3c47e0d..b8495e7 100644 --- a/dtmsvr/config/config.go +++ b/dtmsvr/config/config.go @@ -79,7 +79,8 @@ func (s *Store) GetDBConf() dtmcli.DBConf { } } -type ConfigType struct { +// Type is the type for the config of dtm server +type Type struct { Store Store `yaml:"Store"` TransCronInterval int64 `yaml:"TransCronInterval" default:"3"` TimeoutToFail int64 `yaml:"TimeoutToFail" default:"35"` @@ -97,7 +98,7 @@ type ConfigType struct { } // Config config -var Config = ConfigType{} +var Config = Type{} // MustLoadConfig load config from env and file func MustLoadConfig(confFile string) { diff --git a/dtmsvr/config/config_utils.go b/dtmsvr/config/config_utils.go index b27b684..fa27cc7 100644 --- a/dtmsvr/config/config_utils.go +++ b/dtmsvr/config/config_utils.go @@ -58,7 +58,7 @@ func toUnderscoreUpper(key string) string { return strings.ToUpper(s2) } -func checkConfig(conf *ConfigType) error { +func checkConfig(conf *Type) error { if conf.RetryInterval < 10 { return errors.New("RetryInterval should not be less than 10") } diff --git a/dtmsvr/entry/main.go b/dtmsvr/entry/main.go index e7b5c0e..14d1247 100644 --- a/dtmsvr/entry/main.go +++ b/dtmsvr/entry/main.go @@ -28,7 +28,7 @@ var isReset = flag.Bool("r", false, "Reset dtm server data.") var confFile = flag.String("c", "", "Path to the server configuration file.") // Main is the entry point of dtm server. -func Main(version *string) (*gin.Engine, *config.ConfigType) { +func Main(version *string) (*gin.Engine, *config.Type) { flag.Parse() if *version == "" { *version = "v0.0.0-dev" diff --git a/main.go b/main.go index fb47aec..41593d3 100644 --- a/main.go +++ b/main.go @@ -43,15 +43,15 @@ func getSub(f1 fs.FS, sub string) fs.FS { logger.FatalIfError(err) return f2 } -func addAdmin(app *gin.Engine, conf *config.ConfigType) { +func addAdmin(app *gin.Engine, conf *config.Type) { // for released dtm, serve admin from local files because the build output has been embed // for testing users, proxy admin to target because the build output has not been embed dist := getSub(admin, "admin/dist") index, err := dist.Open("index.html") if err == nil { - defer index.Close() cont, err := ioutil.ReadAll(index) logger.FatalIfError(err) + _ = index.Close() sfile := string(cont) renderIndex := func(c *gin.Context) { c.Header("content-type", "text/html;charset=utf-8")