golib/encoding/gyaml/yaml.go

23 lines
376 B
Go
Raw Normal View History

2023-08-12 21:39:06 +08:00
//
// yaml.go
// Copyright (C) 2023 tiglog <me@tiglog.com>
//
// Distributed under terms of the MIT license.
//
package gyaml
import "gopkg.in/yaml.v3"
// For example:
//
// type T struct {
// F int `yaml:"a,omitempty"`
// B int
// }
// var t T
// gyaml.Decode([]byte("a: 1\nb: 2"), &t)
func Decode(buf []byte, dest any) error {
return yaml.Unmarshal(buf, dest)
}