mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-22 20:40:48 +01:00
Fix GobDecode (#51)
This commit fixes GobDecode, which were mutating a copy of the receiver, rather than the intended pointed struct.
This commit is contained in:
parent
3526cd0bdb
commit
3868940cdd
2 changed files with 6 additions and 1 deletions
|
@ -697,7 +697,7 @@ func (d Decimal) GobEncode() ([]byte, error) {
|
|||
}
|
||||
|
||||
// GobDecode implements the gob.GobDecoder interface for gob serialization.
|
||||
func (d Decimal) GobDecode(data []byte) error {
|
||||
func (d *Decimal) GobDecode(data []byte) error {
|
||||
return d.UnmarshalBinary(data)
|
||||
}
|
||||
|
||||
|
|
|
@ -1637,5 +1637,10 @@ func TestGobEncode(t *testing.T) {
|
|||
if eq != true {
|
||||
t.Errorf("Encoding then decoding mutated Decimal")
|
||||
}
|
||||
|
||||
eq = d1.Equal(d3)
|
||||
if eq != true {
|
||||
t.Errorf("Error gobencoding/decoding %v, got %v", d1, d3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue