From 37706fc9ffb3c5dee3e652fc0d8eef613e4af2d3 Mon Sep 17 00:00:00 2001 From: 13981712066 Date: Fri, 15 Oct 2021 14:11:52 +0800 Subject: [PATCH] For MessagePack Add github.com/tinylib/msgp --- .gitignore | 1 + decimal_gen.go | 35 +++++++++++++++++++++++++++++++++++ go.mod | 2 ++ 3 files changed, 38 insertions(+) create mode 100644 decimal_gen.go diff --git a/.gitignore b/.gitignore index ff36b98..783412a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ # IntelliJ .idea/ *.iml +*.sum # VS code *.code-workspace diff --git a/decimal_gen.go b/decimal_gen.go new file mode 100644 index 0000000..1e07ee4 --- /dev/null +++ b/decimal_gen.go @@ -0,0 +1,35 @@ +package decimal + +// Code generated by github.com/tinylib/msgp DO NOT EDIT. + +import ( + "github.com/tinylib/msgp/msgp" +) + +// MarshalMsg implements msgp.Marshaler +func (z Decimal) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendFloat64(o, z.InexactFloat64()) + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Decimal) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 float64 + zb0001, bts, err = msgp.ReadFloat64Bytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = NewFromFloat(zb0001) + } + o = bts + return +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z Decimal) Msgsize() (s int) { + s = msgp.Float64Size + return +} diff --git a/go.mod b/go.mod index ae1b7aa..57b6f1d 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/shopspring/decimal go 1.13 + +require github.com/tinylib/msgp v1.1.6