Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

v1.1.0

Latest

Choose a tag to compare

@blaubaer blaubaer released this 15 Aug 21:32
9dc1882

Highlights

Before we have to live with always break on unknown fields or not, using:

dec := yaml.NewDecoder(f)
dec.KnownFields(true)

With this change we can define a custom function, like:

dec := yaml.NewDecoder(f)
dec.OnUnknownField(func(node *Node, name reflect.Value, out reflect.Value) error {
   // Do our stuff...
})

Additionally, this can be also changed for yaml.Node, like:

func main() {
  var mt myType
  dec := yaml.NewDecoder(f)
  dec.OnUnknownField(func(node *Node, name reflect.Value, out reflect.Value) error {
     // Do our stuff...
  })
  dec.Decode(&mt)
}

func (m *myType) UnmarshalYAML(value *yaml.Node) error {
    value.OnUnknownField(func(node *Node, name reflect.Value, out reflect.Value) error {
       // Do other stuff...
    }) 
    value.Decode(...)
}

What's Changed

Full Changelog: v1.0.0...v1.1.0