From c62c49f6e25ce90f13f42f4f30c724aa6ba7b2ef Mon Sep 17 00:00:00 2001 From: Bojan Date: Sun, 31 May 2020 22:19:20 -0300 Subject: [PATCH] use runner.LoadConfig --- cmd/ghz/main.go | 3 +-- go.mod | 2 +- go.sum | 4 ++-- runner/config.go | 3 ++- runner/config_test.go | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/ghz/main.go b/cmd/ghz/main.go index d162c436..8e4037c3 100644 --- a/cmd/ghz/main.go +++ b/cmd/ghz/main.go @@ -12,7 +12,6 @@ import ( "strings" "github.com/alecthomas/kingpin" - "github.com/jinzhu/configor" "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -197,7 +196,7 @@ func main() { var cfg runner.Config if cfgPath != "" { - err := configor.Load(&cfg, cfgPath) + err := runner.LoadConfig(cfgPath, &cfg) kingpin.FatalIfError(err, "") args := os.Args[1:] diff --git a/go.mod b/go.mod index 4660808d..8088bc36 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( go.uber.org/multierr v1.3.0 go.uber.org/zap v1.13.0 golang.org/x/net v0.0.0-20191021144547-ec77196f6094 - golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc // indirect + golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f // indirect google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect google.golang.org/grpc v1.24.0 gopkg.in/go-playground/assert.v1 v1.2.1 // indirect diff --git a/go.sum b/go.sum index fb6de0cb..1be0ef5b 100644 --- a/go.sum +++ b/go.sum @@ -258,8 +258,8 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc h1:NCy3Ohtk6Iny5V/reW2Ktypo4zIpWBdRJ1uFMjBxdg8= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f h1:3MlESg/jvTr87F4ttA/q4B+uhe/q6qleC9/DP+IwQmY= +golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= diff --git a/runner/config.go b/runner/config.go index 3bdcf6c2..ae5f95ae 100644 --- a/runner/config.go +++ b/runner/config.go @@ -117,7 +117,8 @@ func checkData(data interface{}) error { return nil } -func loadConfig(p string, c *Config) error { +// LoadConfig loads the config from a file +func LoadConfig(p string, c *Config) error { err := configor.Load(c, p) if err != nil { return err diff --git a/runner/config_test.go b/runner/config_test.go index 8c8a1b1e..6b24351f 100644 --- a/runner/config_test.go +++ b/runner/config_test.go @@ -69,7 +69,7 @@ func TestConfig_Load(t *testing.T) { t.Run("toml "+tt.name, func(t *testing.T) { var actual Config cfgPath := "../testdata/config/config" + strconv.Itoa(i) + ".toml" - err := loadConfig(cfgPath, &actual) + err := LoadConfig(cfgPath, &actual) if tt.ok { assert.NoError(t, err) assert.Equal(t, tt.expected, &actual) @@ -81,7 +81,7 @@ func TestConfig_Load(t *testing.T) { t.Run("json "+tt.name, func(t *testing.T) { var actual Config cfgPath := "../testdata/config/config" + strconv.Itoa(i) + ".toml" - err := loadConfig(cfgPath, &actual) + err := LoadConfig(cfgPath, &actual) if tt.ok { assert.NoError(t, err) assert.Equal(t, tt.expected, &actual) @@ -93,7 +93,7 @@ func TestConfig_Load(t *testing.T) { t.Run("yaml "+tt.name, func(t *testing.T) { var actual Config cfgPath := "../testdata/config/config" + strconv.Itoa(i) + ".yaml" - err := loadConfig(cfgPath, &actual) + err := LoadConfig(cfgPath, &actual) if tt.ok { assert.NoError(t, err) assert.Equal(t, tt.expected, &actual)