From 0ffa05d918441228fbc4bf44550615ee95f58f8c Mon Sep 17 00:00:00 2001 From: Gintautas Miliauskas Date: Fri, 11 Mar 2016 12:29:12 +0000 Subject: [PATCH] Implemented GobDecoder and GobEncoder. --- decimal.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 {