mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
ae87114282
* chore: change interface{} to any * chore: update goctl version to 1.5.0 * chore: update goctl deps
28 lines
610 B
Go
28 lines
610 B
Go
package mapping
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/zeromicro/go-zero/internal/encoding"
|
|
)
|
|
|
|
// UnmarshalTomlBytes unmarshals TOML bytes into the given v.
|
|
func UnmarshalTomlBytes(content []byte, v any, opts ...UnmarshalOption) error {
|
|
b, err := encoding.TomlToJson(content)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return UnmarshalJsonBytes(b, v, opts...)
|
|
}
|
|
|
|
// UnmarshalTomlReader unmarshals TOML from the given io.Reader into the given v.
|
|
func UnmarshalTomlReader(r io.Reader, v any, opts ...UnmarshalOption) error {
|
|
b, err := io.ReadAll(r)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return UnmarshalTomlBytes(b, v, opts...)
|
|
}
|