diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a416b39..e6b3fbe 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,7 +17,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] go: ['1.15', '1.16', '1.17', '1.18'] - tags: ['', 'viper_yaml2', 'viper_toml1'] + tags: ['', 'viper_toml1'] env: GOFLAGS: -mod=readonly diff --git a/README.md b/README.md index c14e892..a86764d 100644 --- a/README.md +++ b/README.md @@ -794,7 +794,7 @@ 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" // ... ) diff --git a/go.mod b/go.mod index 4fca5e8..d55f20e 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( github.com/stretchr/testify v1.7.2 github.com/subosito/gotenv v1.4.0 gopkg.in/ini.v1 v1.66.4 - gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/internal/encoding/yaml/codec.go b/internal/encoding/yaml/codec.go index 24cc19d..431d084 100644 --- a/internal/encoding/yaml/codec.go +++ b/internal/encoding/yaml/codec.go @@ -1,7 +1,5 @@ package yaml -// import "gopkg.in/yaml.v2" - // Codec implements the encoding.Encoder and encoding.Decoder interfaces for YAML encoding. type Codec struct{} diff --git a/internal/encoding/yaml/yaml2.go b/internal/encoding/yaml/yaml2.go deleted file mode 100644 index 4c398c2..0000000 --- a/internal/encoding/yaml/yaml2.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build viper_yaml2 -// +build viper_yaml2 - -package yaml - -import yamlv2 "gopkg.in/yaml.v2" - -var yaml = struct { - Marshal func(in interface{}) (out []byte, err error) - Unmarshal func(in []byte, out interface{}) (err error) -}{ - Marshal: yamlv2.Marshal, - Unmarshal: yamlv2.Unmarshal, -} diff --git a/internal/encoding/yaml/yaml2_test.go b/internal/encoding/yaml/yaml2_test.go deleted file mode 100644 index 8b4fdd2..0000000 --- a/internal/encoding/yaml/yaml2_test.go +++ /dev/null @@ -1,91 +0,0 @@ -//go:build viper_yaml2 -// +build viper_yaml2 - -package yaml - -// original form of the data -const original = `# key-value pair -key: value -list: -- item1 -- item2 -- item3 -map: - key: value - -# nested -# map -nested_map: - 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 -` - -// decoded form of the data -// -// in case of YAML it's slightly different from Viper's internal representation -// (eg. map is decoded into a map with interface key) -var decoded = map[string]interface{}{ - "key": "value", - "list": []interface{}{ - "item1", - "item2", - "item3", - }, - "map": map[interface{}]interface{}{ - "key": "value", - }, - "nested_map": map[interface{}]interface{}{ - "map": map[interface{}]interface{}{ - "key": "value", - "list": []interface{}{ - "item1", - "item2", - "item3", - }, - }, - }, -} - -// Viper's internal representation -var data = map[string]interface{}{ - "key": "value", - "list": []interface{}{ - "item1", - "item2", - "item3", - }, - "map": map[string]interface{}{ - "key": "value", - }, - "nested_map": map[string]interface{}{ - "map": map[string]interface{}{ - "key": "value", - "list": []interface{}{ - "item1", - "item2", - "item3", - }, - }, - }, -} diff --git a/internal/encoding/yaml/yaml3.go b/internal/encoding/yaml/yaml3.go index 3a4775c..c65857b 100644 --- a/internal/encoding/yaml/yaml3.go +++ b/internal/encoding/yaml/yaml3.go @@ -1,6 +1,3 @@ -//go:build !viper_yaml2 -// +build !viper_yaml2 - package yaml import yamlv3 "gopkg.in/yaml.v3" diff --git a/internal/encoding/yaml/yaml3_test.go b/internal/encoding/yaml/yaml3_test.go index e6a86c2..40f688b 100644 --- a/internal/encoding/yaml/yaml3_test.go +++ b/internal/encoding/yaml/yaml3_test.go @@ -1,6 +1,3 @@ -//go:build !viper_yaml2 -// +build !viper_yaml2 - package yaml // original form of the data diff --git a/viper_yaml2_test.go b/viper_yaml2_test.go deleted file mode 100644 index fa12a74..0000000 --- a/viper_yaml2_test.go +++ /dev/null @@ -1,56 +0,0 @@ -//go:build viper_yaml2 -// +build viper_yaml2 - -package viper - -var yamlExample = []byte(`Hacker: true -name: steve -hobbies: -- skateboarding -- snowboarding -- go -clothing: - jacket: leather - trousers: denim - pants: - size: large -age: 35 -eyes : brown -beard: true -`) - -var yamlWriteExpected = []byte(`age: 35 -beard: true -clothing: - jacket: leather - pants: - size: large - trousers: denim -eyes: brown -hacker: true -hobbies: -- skateboarding -- snowboarding -- go -name: steve -`) - -var yamlExampleWithDot = []byte(`Hacker: true -name: steve -hobbies: -- skateboarding -- snowboarding -- go -clothing: - jacket: leather - trousers: denim - pants: - size: large -age: 35 -eyes : brown -beard: true -emails: - steve@hacker.com: - created: 01/02/03 - active: true -`) diff --git a/viper_yaml3_test.go b/viper_yaml3_test.go index ba2d8d7..264446b 100644 --- a/viper_yaml3_test.go +++ b/viper_yaml3_test.go @@ -1,6 +1,3 @@ -//go:build !viper_yaml2 -// +build !viper_yaml2 - package viper var yamlExample = []byte(`Hacker: true