Skip to content

Commit 620edb3

Browse files
committed
bugfix: decimal use a test variable
The patch replaces usage of a test variable DecimalPrecision by a package-level variable decimalPrecision in the decimal package code.
1 parent 48cf0c7 commit 620edb3

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
1414

1515
### Fixed
1616

17+
- Decimal package use a test variable DecimalPrecision instead of a
18+
package-level variable decimalPrecision (#233)
19+
1720
## [1.9.0] - 2022-11-02
1821

1922
The release adds support for the latest version of the

decimal/decimal.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ func NewDecimalFromString(src string) (result *Decimal, err error) {
5858
// MarshalMsgpack serializes the Decimal into a MessagePack representation.
5959
func (decNum *Decimal) MarshalMsgpack() ([]byte, error) {
6060
one := decimal.NewFromInt(1)
61-
maxSupportedDecimal := decimal.New(1, DecimalPrecision).Sub(one) // 10^DecimalPrecision - 1
61+
maxSupportedDecimal := decimal.New(1, decimalPrecision).Sub(one) // 10^DecimalPrecision - 1
6262
minSupportedDecimal := maxSupportedDecimal.Neg().Sub(one) // -10^DecimalPrecision - 1
6363
if decNum.GreaterThan(maxSupportedDecimal) {
64-
return nil, fmt.Errorf("msgpack: decimal number is bigger than maximum supported number (10^%d - 1)", DecimalPrecision)
64+
return nil, fmt.Errorf("msgpack: decimal number is bigger than maximum supported number (10^%d - 1)", decimalPrecision)
6565
}
6666
if decNum.LessThan(minSupportedDecimal) {
67-
return nil, fmt.Errorf("msgpack: decimal number is lesser than minimum supported number (-10^%d - 1)", DecimalPrecision)
67+
return nil, fmt.Errorf("msgpack: decimal number is lesser than minimum supported number (-10^%d - 1)", decimalPrecision)
6868
}
6969

7070
strBuf := decNum.String()

0 commit comments

Comments
 (0)