git » spf » commit d4fddd1

modules: Update gopkg.in/yaml.v2 to v3

author Alberto Bertogli
2022-08-06 09:16:48 UTC
committer Alberto Bertogli
2022-08-06 10:02:27 UTC
parent 0cc947269de74d429675023a9b2f66768328d9fc

modules: Update gopkg.in/yaml.v2 to v3

This patch updates our only dependency (needed just for testing),
gopkg.in/yaml.v2, to its latest major version, gopkg.in/yaml.v3.

While v2 is functional and we don't have any issues with it, v3 is
seeing more active development, and has been stable for a while.

go.mod +1 -1
go.sum +2 -2
yml_test.go +6 -6

diff --git a/go.mod b/go.mod
index 8e41f39..42e7962 100644
--- a/go.mod
+++ b/go.mod
@@ -2,4 +2,4 @@ module blitiri.com.ar/go/spf
 
 go 1.15
 
-require gopkg.in/yaml.v2 v2.3.0
+require gopkg.in/yaml.v3 v3.0.1
diff --git a/go.sum b/go.sum
index 168980d..a62c313 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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/yml_test.go b/yml_test.go
index 737a643..fd45ce8 100644
--- a/yml_test.go
+++ b/yml_test.go
@@ -9,7 +9,7 @@ import (
 	"strings"
 	"testing"
 
-	"gopkg.in/yaml.v2"
+	"gopkg.in/yaml.v3"
 )
 
 var (
@@ -96,17 +96,17 @@ func (r Record) String() string {
 // https://github.com/go-yaml/yaml/issues/100
 type stringSlice []string
 
-func (sl *stringSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (sl *stringSlice) UnmarshalYAML(value *yaml.Node) error {
 	// Try a slice first, and if it works, return it.
 	slice := []string{}
-	if err := unmarshal(&slice); err == nil {
+	if err := value.Decode(&slice); err == nil {
 		*sl = slice
 		return nil
 	}
 
 	// Get a single string, and append it.
 	single := ""
-	if err := unmarshal(&single); err != nil {
+	if err := value.Decode(&single); err != nil {
 		return err
 	}
 	*sl = []string{single}
@@ -121,9 +121,9 @@ type MX struct {
 	Host string
 }
 
-func (mx *MX) UnmarshalYAML(unmarshal func(interface{}) error) error {
+func (mx *MX) UnmarshalYAML(value *yaml.Node) error {
 	seq := []interface{}{}
-	if err := unmarshal(&seq); err != nil {
+	if err := value.Decode(&seq); err != nil {
 		return err
 	}