forked from mirror/viper
feat(encoding): experimental yaml v3 library support
This commit is contained in:
parent
9934fe79e7
commit
f8a13cf704
|
@ -17,6 +17,7 @@ jobs:
|
|||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
go: ['1.14', '1.15', '1.16', '1.17']
|
||||
tags: ['', 'viper_yaml3']
|
||||
env:
|
||||
GOFLAGS: -mod=readonly
|
||||
|
||||
|
@ -30,11 +31,11 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
|
||||
- name: Test
|
||||
run: go test -race -v ./...
|
||||
run: go test -race -tags '${{ matrix.tags }}' -v ./...
|
||||
if: runner.os != 'Windows'
|
||||
|
||||
- name: Test (without race detector)
|
||||
run: go test -v ./...
|
||||
run: go test -tags '${{ matrix.tags }}' -v ./...
|
||||
if: runner.os == 'Windows'
|
||||
|
||||
lint:
|
||||
|
|
2
go.mod
2
go.mod
|
@ -17,6 +17,7 @@ require (
|
|||
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 +66,4 @@ 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
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package yaml
|
||||
|
||||
import "gopkg.in/yaml.v2"
|
||||
// import "gopkg.in/yaml.v2"
|
||||
|
||||
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for YAML encoding.
|
||||
type Codec struct{}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
//go:build !viper_yaml3
|
||||
// +build !viper_yaml3
|
||||
|
||||
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,
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
//go:build viper_yaml3
|
||||
// +build viper_yaml3
|
||||
|
||||
package yaml
|
||||
|
||||
import yamlv3 "gopkg.in/yaml.v3"
|
||||
|
||||
var yaml = struct {
|
||||
Marshal func(in interface{}) (out []byte, err error)
|
||||
Unmarshal func(in []byte, out interface{}) (err error)
|
||||
}{
|
||||
Marshal: yamlv3.Marshal,
|
||||
Unmarshal: yamlv3.Unmarshal,
|
||||
}
|
Loading…
Reference in New Issue