Repository: spf13/viper
Pull request #1357 (2022-05-26 15:12:04)

Make YAML 3 the default
With this change YAML 3 library will become the default. The old version can be used by adding `viper_yaml2` to the list of build tags.

github-actions[bot]: 👋 Thanks for contributing to Viper! You are awesome! 🎉

A maintainer will take a look at your pull request shortly. 👀

In the meantime: We are working on **Viper v2** and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues.

⏰ If you have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9

📣 If you've already given us your feedback, you can still help by spreading the news,
either by sharing the above link or telling people about this on Twitter:

https://twitter.com/sagikazarmark/status/1306904078967074816

**Thank you!** ❤️


Patch:
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 6314980..152c106 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_yaml3', 'viper_toml2']
+        tags: ['', 'viper_yaml2', 'viper_toml2']
     env:
       GOFLAGS: -mod=readonly
 
diff --git a/go.mod b/go.mod
index adc2c31..35ef234 100644
--- a/go.mod
+++ b/go.mod
@@ -18,7 +18,7 @@ require (
 	github.com/subosito/gotenv v1.3.0
 	gopkg.in/ini.v1 v1.66.4
 	gopkg.in/yaml.v2 v2.4.0
-	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
+	gopkg.in/yaml.v3 v3.0.0
 )
 
 require (
diff --git a/go.sum b/go.sum
index 991103d..05ed8ac 100644
--- a/go.sum
+++ b/go.sum
@@ -902,8 +902,9 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
 gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
+gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/internal/encoding/yaml/yaml2.go b/internal/encoding/yaml/yaml2.go
index ca29b84..4c398c2 100644
--- a/internal/encoding/yaml/yaml2.go
+++ b/internal/encoding/yaml/yaml2.go
@@ -1,5 +1,5 @@
-//go:build !viper_yaml3
-// +build !viper_yaml3
+//go:build viper_yaml2
+// +build viper_yaml2
 
 package yaml
 
diff --git a/internal/encoding/yaml/yaml3.go b/internal/encoding/yaml/yaml3.go
index 96b8957..3a4775c 100644
--- a/internal/encoding/yaml/yaml3.go
+++ b/internal/encoding/yaml/yaml3.go
@@ -1,5 +1,5 @@
-//go:build viper_yaml3
-// +build viper_yaml3
+//go:build !viper_yaml2
+// +build !viper_yaml2
 
 package yaml
 


Test patch:
diff --git a/internal/encoding/yaml/yaml2_test.go b/internal/encoding/yaml/yaml2_test.go
index e39d429..8b4fdd2 100644
--- a/internal/encoding/yaml/yaml2_test.go
+++ b/internal/encoding/yaml/yaml2_test.go
@@ -1,5 +1,5 @@
-//go:build !viper_yaml3
-// +build !viper_yaml3
+//go:build viper_yaml2
+// +build viper_yaml2
 
 package yaml
 
diff --git a/internal/encoding/yaml/yaml3_test.go b/internal/encoding/yaml/yaml3_test.go
index 6beb263..e6a86c2 100644
--- a/internal/encoding/yaml/yaml3_test.go
+++ b/internal/encoding/yaml/yaml3_test.go
@@ -1,5 +1,5 @@
-//go:build viper_yaml3
-// +build viper_yaml3
+//go:build !viper_yaml2
+// +build !viper_yaml2
 
 package yaml
 
diff --git a/viper_yaml2_test.go b/viper_yaml2_test.go
index 5a8a51e..fa12a74 100644
--- a/viper_yaml2_test.go
+++ b/viper_yaml2_test.go
@@ -1,5 +1,5 @@
-//go:build !viper_yaml3
-// +build !viper_yaml3
+//go:build viper_yaml2
+// +build viper_yaml2
 
 package viper
 
diff --git a/viper_yaml3_test.go b/viper_yaml3_test.go
index c397865..ba2d8d7 100644
--- a/viper_yaml3_test.go
+++ b/viper_yaml3_test.go
@@ -1,5 +1,5 @@
-//go:build viper_yaml3
-// +build viper_yaml3
+//go:build !viper_yaml2
+// +build !viper_yaml2
 
 package viper