yaml.go 428 B

123456789101112131415161718192021222324
  1. package yaml
  2. import (
  3. "github.com/ghodss/yaml"
  4. "gogs.baozhida.cn/zoie/OAuth-core/config/encoder"
  5. )
  6. type yamlEncoder struct{}
  7. func (y yamlEncoder) Encode(v interface{}) ([]byte, error) {
  8. return yaml.Marshal(v)
  9. }
  10. func (y yamlEncoder) Decode(d []byte, v interface{}) error {
  11. return yaml.Unmarshal(d, v)
  12. }
  13. func (y yamlEncoder) String() string {
  14. return "yaml"
  15. }
  16. func NewEncoder() encoder.Encoder {
  17. return yamlEncoder{}
  18. }