From de6a38c0f3e1f21349e6361b8fe2829a09cf02b8 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Tue, 20 Oct 2020 17:36:41 +0300 Subject: GolangCi warnings fix --- plugins/config/tests/config_test.go | 3 +-- plugins/config/viper.go | 7 +------ plugins/factory/app.go | 1 - plugins/factory/tests/factory_test.go | 3 +-- plugins/rpc/config_test.go | 2 -- 5 files changed, 3 insertions(+), 13 deletions(-) (limited to 'plugins') diff --git a/plugins/config/tests/config_test.go b/plugins/config/tests/config_test.go index cf5d8489..c85a841f 100644 --- a/plugins/config/tests/config_test.go +++ b/plugins/config/tests/config_test.go @@ -40,7 +40,7 @@ func TestViperProvider_Init(t *testing.T) { } // stop by CTRL+C - c := make(chan os.Signal) + c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) tt := time.NewTicker(time.Second * 2) @@ -63,5 +63,4 @@ func TestViperProvider_Init(t *testing.T) { return } } - } diff --git a/plugins/config/viper.go b/plugins/config/viper.go index b276dbe2..0c34313c 100644 --- a/plugins/config/viper.go +++ b/plugins/config/viper.go @@ -14,7 +14,6 @@ type ViperProvider struct { Prefix string } -//////// ENDURE ////////// func (v *ViperProvider) Init() error { v.viper = viper.New() @@ -35,8 +34,6 @@ func (v *ViperProvider) Init() error { return v.viper.ReadInConfig() } -///////////// VIPER /////////////// - // Overwrite overwrites existing config with provided values func (v *ViperProvider) Overwrite(values map[string]string) error { if len(values) != 0 { @@ -71,8 +68,6 @@ func (v *ViperProvider) Has(name string) bool { return v.viper.IsSet(name) } -/////////// PRIVATE ////////////// - func parseFlag(flag string) (string, string, error) { if !strings.Contains(flag, "=") { return "", "", fmt.Errorf("invalid flag `%s`", flag) @@ -88,7 +83,7 @@ func parseValue(value string) string { if escape == '"' || escape == '\'' || escape == '`' { value = strings.Trim(value, string(escape)) - value = strings.Replace(value, fmt.Sprintf("\\%s", string(escape)), string(escape), -1) + value = strings.ReplaceAll(value, fmt.Sprintf("\\%s", string(escape)), string(escape)) } return value diff --git a/plugins/factory/app.go b/plugins/factory/app.go index 4106b96f..e4002963 100644 --- a/plugins/factory/app.go +++ b/plugins/factory/app.go @@ -33,7 +33,6 @@ type AppConfig struct { type App struct { cfg AppConfig configProvider config.Provider - factory roadrunner.Factory } func (app *App) Init(provider config.Provider) error { diff --git a/plugins/factory/tests/factory_test.go b/plugins/factory/tests/factory_test.go index 72e28f84..5347083a 100644 --- a/plugins/factory/tests/factory_test.go +++ b/plugins/factory/tests/factory_test.go @@ -57,7 +57,7 @@ func TestFactory(t *testing.T) { } // stop by CTRL+C - c := make(chan os.Signal) + c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) tt := time.NewTicker(time.Second * 2) @@ -80,5 +80,4 @@ func TestFactory(t *testing.T) { return } } - } diff --git a/plugins/rpc/config_test.go b/plugins/rpc/config_test.go index dcc24ec1..36927dd2 100644 --- a/plugins/rpc/config_test.go +++ b/plugins/rpc/config_test.go @@ -4,13 +4,11 @@ import ( "testing" json "github.com/json-iterator/go" - //"github.com/spiral/roadrunner/service" "github.com/stretchr/testify/assert" ) type testCfg struct{ cfg string } - func (cfg *testCfg) Unmarshal(out interface{}) error { j := json.ConfigCompatibleWithStandardLibrary return j.Unmarshal([]byte(cfg.cfg), out) -- cgit v1.2.3