Implemented GobDecoder and GobEncoder.

This commit is contained in:
Gintautas Miliauskas 2016-03-11 12:29:12 +00:00
parent 3b7679240e
commit 0ffa05d918

View file

@ -532,6 +532,16 @@ func (d Decimal) MarshalText() (text []byte, err error) {
return []byte(d.String()), nil
}
// GobDecode implements the gob.GobDecoder interface for gob serialization.
func (d *Decimal) GobDecode(data []byte) error {
return d.UnmarshalText(data)
}
// GobEncode implements the gob.GobEncoder interface for gob serialization.
func (d Decimal) GobEncode() ([]byte, error) {
return d.MarshalText()
}
// NOTE: buggy, unintuitive, and DEPRECATED! Use StringFixed instead.
// StringScaled first scales the decimal then calls .String() on it.
func (d Decimal) StringScaled(exp int32) string {