From f86e6f60b76f0b19e53ff2fc409286667f7de9e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20Casta=C3=B1=C3=A9?= Date: Wed, 25 May 2022 21:44:04 +0200 Subject: [PATCH] Upgrade yaml to v3 As requested in "Update the yaml dependency to v3? #206". --- README.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- mergo_test.go | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fee77ac..ab49fd7 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ func main() { Note: if test are failing due missing package, please execute: - go get gopkg.in/yaml.v2 + go get gopkg.in/yaml.v3 ### Transformers diff --git a/go.mod b/go.mod index 3d689d9..6f476d6 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/imdario/mergo go 1.13 -require gopkg.in/yaml.v2 v2.3.0 +require gopkg.in/yaml.v3 v3.0.0 diff --git a/go.sum b/go.sum index 168980d..223abcb 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/mergo_test.go b/mergo_test.go index 1259ec2..6b3eba7 100644 --- a/mergo_test.go +++ b/mergo_test.go @@ -13,7 +13,7 @@ import ( "time" "github.com/imdario/mergo" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) type simpleTest struct { @@ -603,18 +603,18 @@ func TestMapsWithNilPointer(t *testing.T) { func TestYAMLMaps(t *testing.T) { thing := loadYAML("testdata/thing.yml") license := loadYAML("testdata/license.yml") - ft := thing["fields"].(map[interface{}]interface{}) - fl := license["fields"].(map[interface{}]interface{}) + ft := thing["fields"].(map[string]interface{}) + fl := license["fields"].(map[string]interface{}) // license has one extra field (site) and another already existing in thing (author) that Mergo won't override. expectedLength := len(ft) + len(fl) - 1 if err := mergo.Merge(&license, thing); err != nil { t.Error(err.Error()) } - currentLength := len(license["fields"].(map[interface{}]interface{})) + currentLength := len(license["fields"].(map[string]interface{})) if currentLength != expectedLength { t.Errorf(`thing not merged in license properly, license must have %d elements instead of %d`, expectedLength, currentLength) } - fields := license["fields"].(map[interface{}]interface{}) + fields := license["fields"].(map[string]interface{}) if _, ok := fields["id"]; !ok { t.Errorf(`thing not merged in license properly, license must have a new id field from thing`) }