mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-03 15:27:45 +00:00
Update dependencies (#1813)
This commit is contained in:
42
vendor/github.com/spf13/viper/internal/encoding/toml/codec.go
generated
vendored
42
vendor/github.com/spf13/viper/internal/encoding/toml/codec.go
generated
vendored
@ -1,3 +1,6 @@
|
||||
//go:build !viper_toml2
|
||||
// +build !viper_toml2
|
||||
|
||||
package toml
|
||||
|
||||
import (
|
||||
@ -7,39 +10,30 @@ import (
|
||||
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for TOML encoding.
|
||||
type Codec struct{}
|
||||
|
||||
func (Codec) Encode(v interface{}) ([]byte, error) {
|
||||
if m, ok := v.(map[string]interface{}); ok {
|
||||
t, err := toml.TreeFromMap(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s, err := t.ToTomlString()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return []byte(s), nil
|
||||
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
|
||||
t, err := toml.TreeFromMap(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return toml.Marshal(v)
|
||||
s, err := t.ToTomlString()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return []byte(s), nil
|
||||
}
|
||||
|
||||
func (Codec) Decode(b []byte, v interface{}) error {
|
||||
func (Codec) Decode(b []byte, v map[string]interface{}) error {
|
||||
tree, err := toml.LoadBytes(b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if m, ok := v.(*map[string]interface{}); ok {
|
||||
vmap := *m
|
||||
tmap := tree.ToMap()
|
||||
for k, v := range tmap {
|
||||
vmap[k] = v
|
||||
}
|
||||
|
||||
return nil
|
||||
tmap := tree.ToMap()
|
||||
for key, value := range tmap {
|
||||
v[key] = value
|
||||
}
|
||||
|
||||
return tree.Unmarshal(v)
|
||||
return nil
|
||||
}
|
||||
|
19
vendor/github.com/spf13/viper/internal/encoding/toml/codec2.go
generated
vendored
Normal file
19
vendor/github.com/spf13/viper/internal/encoding/toml/codec2.go
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
//go:build viper_toml2
|
||||
// +build viper_toml2
|
||||
|
||||
package toml
|
||||
|
||||
import (
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
)
|
||||
|
||||
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for TOML encoding.
|
||||
type Codec struct{}
|
||||
|
||||
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
|
||||
return toml.Marshal(v)
|
||||
}
|
||||
|
||||
func (Codec) Decode(b []byte, v map[string]interface{}) error {
|
||||
return toml.Unmarshal(b, &v)
|
||||
}
|
Reference in New Issue
Block a user