mirror of
https://github.com/number571/go-peer.git
synced 2026-09-12 19:50:00 +05:00
20 lines
332 B
Go
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
|
|
}
|