You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package yaml
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.diulo.com/mogfee/kit/encoding"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Name is the name registered for the yaml codec.
|
|
|
|
const Name = "yaml"
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
encoding.RegisterCodec(codec{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// codec is a Codec implementation with yaml.
|
|
|
|
type codec struct{}
|
|
|
|
|
|
|
|
func (codec) Marshal(v interface{}) ([]byte, error) {
|
|
|
|
return yaml.Marshal(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (codec) Unmarshal(data []byte, v interface{}) error {
|
|
|
|
return yaml.Unmarshal(data, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (codec) Name() string {
|
|
|
|
return Name
|
|
|
|
}
|