diff --git a/decimal.go b/decimal.go index ec18233..224de26 100644 --- a/decimal.go +++ b/decimal.go @@ -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 {