File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1454,6 +1454,12 @@ func (d *Decimal) GobDecode(data []byte) error {
14541454 return d .UnmarshalBinary (data )
14551455}
14561456
1457+ // GoString implements fmt.GoStringer and formats %#v to be printed in Go
1458+ // source code.
1459+ func (d * Decimal ) GoString () string {
1460+ return `decimal.RequireFromString("` + d .String () + `")`
1461+ }
1462+
14571463// StringScaled first scales the decimal then calls .String() on it.
14581464// NOTE: buggy, unintuitive, and DEPRECATED! Use StringFixed instead.
14591465func (d Decimal ) StringScaled (exp int32 ) string {
@@ -1682,6 +1688,15 @@ func (d NullDecimal) MarshalText() (text []byte, err error) {
16821688 return d .Decimal .MarshalText ()
16831689}
16841690
1691+ // GoString implements fmt.GoStringer and formats %#v to be printed in Go
1692+ // source code.
1693+ func (d NullDecimal ) GoString () string {
1694+ if ! d .Valid {
1695+ return "decimal.NullDecimal{Valid: false}"
1696+ }
1697+ return `decimal.NewNullDecimal(` + d .Decimal .GoString () + `)`
1698+ }
1699+
16851700// Trig functions
16861701
16871702// Atan returns the arctangent, in radians, of x.
You can’t perform that action at this time.
0 commit comments