diff --git a/config.go b/config.go index f7f8ce85..d63e7bbb 100644 --- a/config.go +++ b/config.go @@ -258,7 +258,7 @@ func RegisterCloser(closer io.Closer) Store { } // RegisterCloser adds a closer to the list of closers. -// Closers are closed when an error occured while reloading a config and the ExitOnError config is set to true +// Closers are closed when an error occurred while reloading a config and the ExitOnError config is set to true func (c *S) RegisterCloser(closer io.Closer) Store { c.Closers = append(c.Closers, closer) return c diff --git a/config_test.go b/config_test.go index f7f55ac4..89c3445e 100644 --- a/config_test.go +++ b/config_test.go @@ -85,7 +85,7 @@ func TestConfigWatcherLoader(t *testing.T) { RegisterLoader( &DummyLoader{ [][2]string{ - [2]string{ + { "foo", "bar", }, }, @@ -110,7 +110,7 @@ func TestConfigWatcherLoader(t *testing.T) { RegisterLoader( &DummyLoader{ [][2]string{ - [2]string{ + { "foo", "bar", }, }, diff --git a/loader/kletcd/etcdloader_test.go b/loader/kletcd/etcdloader_test.go index 7d6c32e6..c758b3c3 100644 --- a/loader/kletcd/etcdloader_test.go +++ b/loader/kletcd/etcdloader_test.go @@ -51,7 +51,7 @@ func TestEtcdLoader(t *testing.T) { mockClient.EXPECT().Get(ctx, "key1").Return( &clientv3.GetResponse{ Kvs: []*mvccpb.KeyValue{ - &mvccpb.KeyValue{ + { Key: []byte(`key1`), Value: []byte(`bar`), }, @@ -63,7 +63,7 @@ func TestEtcdLoader(t *testing.T) { mockClient.EXPECT().Get(ctx, "key2").Return( &clientv3.GetResponse{ Kvs: []*mvccpb.KeyValue{ - &mvccpb.KeyValue{ + { Key: []byte(`key2`), Value: []byte(`foo`), }, @@ -119,11 +119,11 @@ func TestEtcdLoader(t *testing.T) { mockClient.EXPECT().Get(ctx, "key1").Return( &clientv3.GetResponse{ Kvs: []*mvccpb.KeyValue{ - &mvccpb.KeyValue{ + { Key: []byte(`key1`), Value: []byte(`bar`), }, - &mvccpb.KeyValue{ + { Key: []byte(`key2`), Value: []byte(`foo`), }, @@ -180,11 +180,11 @@ func TestEtcdLoader(t *testing.T) { mockClient.EXPECT().Get(ctx, "key1").Times(1).Return( &clientv3.GetResponse{ Kvs: []*mvccpb.KeyValue{ - &mvccpb.KeyValue{ + { Key: []byte(`key1`), Value: []byte(`bar`), }, - &mvccpb.KeyValue{ + { Key: []byte(`key2`), Value: []byte(`foo`), }, @@ -209,11 +209,11 @@ func TestEtcdLoader(t *testing.T) { mockClient.EXPECT().Get(ctx, "key1").MinTimes(1).Return( &clientv3.GetResponse{ Kvs: []*mvccpb.KeyValue{ - &mvccpb.KeyValue{ + { Key: []byte(`key1`), Value: []byte(`bar`), }, - &mvccpb.KeyValue{ + { Key: []byte(`key`), Value: []byte(`foo`), }, @@ -265,11 +265,11 @@ func TestEtcdLoader(t *testing.T) { mockClient.EXPECT().Get(ctx, "key1").Return( &clientv3.GetResponse{ Kvs: []*mvccpb.KeyValue{ - &mvccpb.KeyValue{ + { Key: []byte(`key1`), Value: []byte(`bar`), }, - &mvccpb.KeyValue{ + { Key: []byte(`key2`), Value: []byte(`foo`), }, @@ -367,7 +367,7 @@ func TestEtcdLoader(t *testing.T) { mockClient.EXPECT().Get(ctx, "key1").Return( &clientv3.GetResponse{ Kvs: []*mvccpb.KeyValue{ - &mvccpb.KeyValue{ + { Key: []byte(`key1`), Value: []byte(`bar`), }, diff --git a/loader/klvault/vaultloader_test.go b/loader/klvault/vaultloader_test.go index c3c17cd8..ada7e464 100644 --- a/loader/klvault/vaultloader_test.go +++ b/loader/klvault/vaultloader_test.go @@ -83,7 +83,7 @@ func TestVaultLoader(t *testing.T) { }, nil, ) - lC.EXPECT().ReadWithData("dummy/secret/data/path3", map[string][]string{"version": []string{"1"}}).Return( + lC.EXPECT().ReadWithData("dummy/secret/data/path3", map[string][]string{"version": {"1"}}).Return( &vault.Secret{ Data: map[string]interface{}{ "data": map[string]interface{}{ diff --git a/parser/kptoml/tomlparser.go b/parser/kptoml/tomlparser.go index 567c208f..02d50d3b 100644 --- a/parser/kptoml/tomlparser.go +++ b/parser/kptoml/tomlparser.go @@ -3,10 +3,10 @@ package kptoml import ( "io" + "github.com/BurntSushi/toml" "github.com/lalamove/konfig" "github.com/lalamove/konfig/parser" "github.com/lalamove/konfig/parser/kpmap" - "github.com/BurntSushi/toml" ) // Parser parses the given json io.Reader and adds values in dot.path notation into the konfig.Store diff --git a/test/configfile_test.go b/test/configfile_test.go index ee9ddaf8..07c8bfc9 100644 --- a/test/configfile_test.go +++ b/test/configfile_test.go @@ -70,7 +70,7 @@ func TestYAMLFile(t *testing.T) { konfig.RegisterLoader( klfile.New(&klfile.Config{ Files: []klfile.File{ - klfile.File{ + { Path: "./data/cfg.yml", Parser: kpyaml.Parser, }, diff --git a/value_test.go b/value_test.go index 61b53cf3..404fb4cf 100644 --- a/value_test.go +++ b/value_test.go @@ -75,21 +75,21 @@ func TestSetStruct(t *testing.T) { TT: 2, }, SubMapTPtr: map[string]*TestConfigSub{ - "foo": &TestConfigSub{ + "foo": { VV: "woop", TT: 1, }, - "bar": &TestConfigSub{ + "bar": { VV: "hello", TT: 1, }, }, SubMapT: map[string]TestConfigSub{ - "foo": TestConfigSub{ + "foo": { VV: "woop", TT: 1, }, - "bar": TestConfigSub{ + "bar": { VV: "hello", TT: 1, },