1
0
mirror of https://github.com/go-kratos/kratos.git synced 2026-05-22 10:15:24 +02:00
Files
kratos/encoding/yaml/yaml.go
T

29 lines
497 B
Go
Raw Normal View History

2021-05-17 21:52:23 +08:00
package yaml
import (
"github.com/go-kratos/kratos/v2/encoding"
2021-06-12 20:20:18 +08:00
"gopkg.in/yaml.v3"
2021-05-17 21:52:23 +08:00
)
2021-06-30 11:55:01 +08:00
// Name is the name registered for the yaml codec.
2021-05-17 21:52:23 +08:00
const Name = "yaml"
func init() {
encoding.RegisterCodec(codec{})
}
2021-06-30 11:55:01 +08:00
// codec is a Codec implementation with yaml.
2021-05-17 21:52:23 +08:00
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
}