2019-05-30 23:11:13 +01:00
|
|
|
package yaml
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ghodss/yaml"
|
2020-08-19 17:47:17 +03:00
|
|
|
"github.com/unistack-org/micro/v3/config/encoder"
|
2019-05-30 23:11:13 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type yamlEncoder struct{}
|
|
|
|
|
|
|
|
func (y yamlEncoder) Encode(v interface{}) ([]byte, error) {
|
|
|
|
return yaml.Marshal(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (y yamlEncoder) Decode(d []byte, v interface{}) error {
|
|
|
|
return yaml.Unmarshal(d, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (y yamlEncoder) String() string {
|
|
|
|
return "yaml"
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewEncoder() encoder.Encoder {
|
|
|
|
return yamlEncoder{}
|
|
|
|
}
|