diff --git a/config/config.go b/config/config.go index 3d5c460d6..382123c24 100644 --- a/config/config.go +++ b/config/config.go @@ -3,11 +3,11 @@ package config import ( "context" "errors" - "github.com/go-kratos/kratos/v2/encoding" "reflect" "sync" "time" + "github.com/go-kratos/kratos/v2/encoding" // init encoding _ "github.com/go-kratos/kratos/v2/encoding/json" _ "github.com/go-kratos/kratos/v2/encoding/proto" diff --git a/config/config_test.go b/config/config_test.go index 9a166b00e..090c3cd3f 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -3,6 +3,9 @@ package config import ( "errors" "testing" + + "github.com/go-kratos/kratos/v2/encoding" + _ "github.com/go-kratos/kratos/v2/encoding/json" ) const ( @@ -128,9 +131,10 @@ func TestConfig(t *testing.T) { jSource := newTestJSONSource(_testJSON) opts := options{ - sources: []Source{jSource}, - decoder: defaultDecoder, - resolver: defaultResolver, + sources: []Source{jSource}, + decoder: defaultDecoder, + resolver: defaultResolver, + mergeCodec: encoding.GetCodec("json"), } cf := &config{} cf.opts = opts diff --git a/config/reader_test.go b/config/reader_test.go index 11b2d990e..d46890996 100644 --- a/config/reader_test.go +++ b/config/reader_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/go-kratos/kratos/v2/encoding" + _ "github.com/go-kratos/kratos/v2/encoding/json" ) func TestReader_Merge(t *testing.T) { @@ -183,7 +184,8 @@ func TestReader_Source(t *testing.T) { } return fmt.Errorf("unsupported key: %s format: %s", kv.Key, kv.Format) }, - resolver: defaultResolver, + resolver: defaultResolver, + mergeCodec: encoding.GetCodec("json"), } r := newReader(opts) err = r.Merge(&KeyValue{