28 lines
619 B
Go
Executable File
28 lines
619 B
Go
Executable File
package mapping
|
|
|
|
import (
|
|
"io"
|
|
|
|
"git.wishpal.cn/wishpal_ironfan/xframe/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...)
|
|
}
|