Skip to content

Commit

Permalink
Merge pull request #1075 from k1LoW/use-math-max-int
Browse files Browse the repository at this point in the history
Use math.MaxInt instead
  • Loading branch information
k1LoW authored Nov 17, 2024
2 parents 6b8b76f + 7eb2f44 commit 3a20ef3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runn

import (
"fmt"
"math"
"reflect"
"strconv"
"strings"
Expand All @@ -21,8 +22,6 @@ import (
const (
delimStart = "{{"
delimEnd = "}}"
maxUint = ^uint(0) //nostyle:repetition
maxInt = int(maxUint >> 1) //nostyle:repetition
)

var baseTreePrinterOptions = []exprtrace.TreePrinterOption{
Expand Down Expand Up @@ -121,7 +120,7 @@ func EvalCount(count string, store exprtrace.EvalEnv) (int, error) {
case int64:
c = int(v)
case uint64:
if v > uint64(maxInt) {
if v > math.MaxInt {
return 0, fmt.Errorf("invalid count: evaluated %s, but got %T(%v): %w", count, r, r, err)
}
c = int(v) //nolint:gosec
Expand Down

0 comments on commit 3a20ef3

Please sign in to comment.