diff --git a/README.md b/README.md index 9712e70..350ea00 100644 --- a/README.md +++ b/README.md @@ -195,12 +195,12 @@ var yamlExample = []byte(` Hacker: true name: steve hobbies: -- skateboarding -- snowboarding -- go + - skateboarding + - snowboarding + - go clothing: - jacket: leather - trousers: denim + jacket: leather + trousers: denim age: 35 eyes : brown beard: true @@ -794,8 +794,8 @@ You can use your favorite format's marshaller with the config returned by `AllSe ```go import ( - yaml "gopkg.in/yaml.v2" - // ... + yaml "gopkg.in/yaml.v3" + // ... ) func yamlStringSettings() string { diff --git a/go.mod b/go.mod index 91f39a3..42d65be 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/stretchr/testify v1.7.0 github.com/subosito/gotenv v1.2.0 gopkg.in/ini.v1 v1.66.2 - gopkg.in/yaml.v2 v2.4.0 + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) require ( @@ -65,5 +65,5 @@ require ( google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect google.golang.org/grpc v1.43.0 // indirect google.golang.org/protobuf v1.27.1 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/internal/encoding/yaml/codec.go b/internal/encoding/yaml/codec.go index 5fa4b39..7f64b4d 100644 --- a/internal/encoding/yaml/codec.go +++ b/internal/encoding/yaml/codec.go @@ -1,6 +1,8 @@ package yaml -import "gopkg.in/yaml.v2" +import ( + "gopkg.in/yaml.v3" +) // Codec implements the encoding.Encoder and encoding.Decoder interfaces for YAML encoding. type Codec struct{} diff --git a/internal/encoding/yaml/codec_test.go b/internal/encoding/yaml/codec_test.go index d76a6c6..9fe3838 100644 --- a/internal/encoding/yaml/codec_test.go +++ b/internal/encoding/yaml/codec_test.go @@ -9,38 +9,38 @@ import ( const original = `# key-value pair key: value list: -- item1 -- item2 -- item3 + - item1 + - item2 + - item3 map: - key: value + key: value # nested # map nested_map: - map: - key: value - list: - - item1 - - item2 - - item3 + map: + key: value + list: + - item1 + - item2 + - item3 ` // encoded form of the data const encoded = `key: value list: -- item1 -- item2 -- item3 -map: - key: value -nested_map: - map: - key: value - list: - item1 - item2 - item3 +map: + key: value +nested_map: + map: + key: value + list: + - item1 + - item2 + - item3 ` // decoded form of the data @@ -54,11 +54,11 @@ var decoded = map[string]interface{}{ "item2", "item3", }, - "map": map[interface{}]interface{}{ + "map": map[string]interface{}{ "key": "value", }, - "nested_map": map[interface{}]interface{}{ - "map": map[interface{}]interface{}{ + "nested_map": map[string]interface{}{ + "map": map[string]interface{}{ "key": "value", "list": []interface{}{ "item1", diff --git a/viper_test.go b/viper_test.go index 8c864f1..c7c846c 100644 --- a/viper_test.go +++ b/viper_test.go @@ -36,14 +36,14 @@ import ( var yamlExample = []byte(`Hacker: true name: steve hobbies: -- skateboarding -- snowboarding -- go + - skateboarding + - snowboarding + - go clothing: - jacket: leather - trousers: denim - pants: - size: large + jacket: leather + trousers: denim + pants: + size: large age: 35 eyes : brown beard: true @@ -1561,16 +1561,16 @@ p_batters.batter.type = Regular var yamlWriteExpected = []byte(`age: 35 beard: true clothing: - jacket: leather - pants: - size: large - trousers: denim + jacket: leather + pants: + size: large + trousers: denim eyes: brown hacker: true hobbies: -- skateboarding -- snowboarding -- go + - skateboarding + - snowboarding + - go name: steve `) @@ -2413,21 +2413,21 @@ func TestUnmarshal_DotSeparatorBackwardCompatibility(t *testing.T) { var yamlExampleWithDot = []byte(`Hacker: true name: steve hobbies: - - skateboarding - - snowboarding - - go + - skateboarding + - snowboarding + - go clothing: - jacket: leather - trousers: denim - pants: - size: large + jacket: leather + trousers: denim + pants: + size: large age: 35 eyes : brown beard: true emails: - steve@hacker.com: - created: 01/02/03 - active: true + steve@hacker.com: + created: 01/02/03 + active: true `) func TestKeyDelimiter(t *testing.T) {