Skip to content

Commit

Permalink
fix: govet shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
DaruZero committed May 23, 2023
1 parent db46aa3 commit a2e148a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions parse/quantity.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func Quantity(str string) (int, error) {
}

amount := new(inf.Dec)
if _, ok := amount.SetString(value); !ok {
if _, ok = amount.SetString(value); !ok {
return 0, ErrNumeric
}

Expand All @@ -161,15 +161,13 @@ func Quantity(str string) (int, error) {
// if you want some resources, you should get some resources, even if you asked for way too small
// of an amount. Arguably, this should be inf.RoundHalfUp (normal rounding), but that would have
// the side effect of rounding values < .5n to zero.
if v, ok := amount.Unscaled(); v != int64(0) || !ok {
var v int64
if v, ok = amount.Unscaled(); v != int64(0) || !ok {
amount.Round(amount, inf.Scale(-Nano), inf.RoundUp)
}

final, ok := amount.Unscaled()
if !ok {
return 0, ErrNumeric
}
return AsInt(int(final), Scale(amount.Scale()))
v = amount.UnscaledBig().Int64()
return AsInt(int(v), Scale(amount.Scale()))
}

// parseQuantityString is a fast scanner for quantity values.
Expand Down

0 comments on commit a2e148a

Please sign in to comment.