wttr.in/internal/util/yaml.go

16 lines
303 B
Go
Raw Normal View History

2022-12-04 20:16:39 +00:00
package util
import (
"bytes"
"gopkg.in/yaml.v3"
)
// YamlUnmarshalStrict unmarshals YAML data with an error when unknown fields are present.
func YamlUnmarshalStrict(in []byte, out interface{}) error {
dec := yaml.NewDecoder(bytes.NewReader(in))
dec.KnownFields(true)
2022-12-11 13:28:34 +00:00
2022-12-04 20:16:39 +00:00
return dec.Decode(out)
}