mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
dcfc9b79f1
* feat: accept camelcase for config keys * chore: refactor * chore: refactor * chore: add more tests * chore: refactor * fix: map elements of array
28 lines
603 B
Go
28 lines
603 B
Go
package mapping
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/zeromicro/go-zero/internal/encoding"
|
|
)
|
|
|
|
// UnmarshalYamlBytes unmarshals content into v.
|
|
func UnmarshalYamlBytes(content []byte, v interface{}, opts ...UnmarshalOption) error {
|
|
b, err := encoding.YamlToJson(content)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return UnmarshalJsonBytes(b, v, opts...)
|
|
}
|
|
|
|
// UnmarshalYamlReader unmarshals content from reader into v.
|
|
func UnmarshalYamlReader(reader io.Reader, v interface{}, opts ...UnmarshalOption) error {
|
|
b, err := io.ReadAll(reader)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return UnmarshalYamlBytes(b, v, opts...)
|
|
}
|