go-peer/pkg/encoding/serialize_yaml.go
2024-10-31 05:23:49 +07:00

20 lines
332 B
Go

package encoding
import (
"errors"
yaml "gopkg.in/yaml.v2"
)
func SerializeYAML(pData interface{}) []byte {
res, _ := yaml.Marshal(pData)
return res
}
func DeserializeYAML(pData []byte, pRes interface{}) error {
if err := yaml.Unmarshal(pData, pRes); err != nil {
return errors.Join(ErrDeserialize, err)
}
return nil
}