Skip to content

Commit 853a3ca

Browse files
lint: use min/max builtins where possible
1 parent c912323 commit 853a3ca

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

json/golang_scanner_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ func TestIndentErrors(t *testing.T) {
199199
func diff(t *testing.T, a, b []byte) {
200200
for i := 0; ; i++ {
201201
if i >= len(a) || i >= len(b) || a[i] != b[i] {
202-
j := i - 10
203-
if j < 0 {
204-
j = 0
205-
}
202+
j := max(0, i-10)
206203
t.Errorf("diverge at %d: «%s» vs «%s»", i, trim(a[j:]), trim(b[j:]))
207204
return
208205
}
@@ -282,9 +279,7 @@ func genArray(n int) []interface{} {
282279

283280
func genMap(n int) map[string]interface{} {
284281
f := int(math.Abs(rand.NormFloat64()) * math.Min(10, float64(n/2)))
285-
if f > n {
286-
f = n
287-
}
282+
f = min(f, n)
288283
if n > 0 && f == 0 {
289284
f = 1
290285
}

0 commit comments

Comments
 (0)