Skip to content

Commit 732dfcf

Browse files
committed
internal/difflib: rename funcs that collided with built-ins
min, max are a builtin since go1.21; https://go.dev/doc/go1.21#language Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 7d95f55 commit 732dfcf

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

internal/difflib/difflib.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ This file is trimmed to only the parts used by this repository.
77
*/
88
package difflib // import "gotest.tools/v3/internal/difflib"
99

10-
func min(a, b int) int {
10+
func minInt(a, b int) int {
1111
if a < b {
1212
return a
1313
}
1414
return b
1515
}
1616

17-
func max(a, b int) int {
17+
func maxInt(a, b int) int {
1818
if a > b {
1919
return a
2020
}
@@ -397,12 +397,12 @@ func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode {
397397
if codes[0].Tag == 'e' {
398398
c := codes[0]
399399
i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
400-
codes[0] = OpCode{c.Tag, max(i1, i2-n), i2, max(j1, j2-n), j2}
400+
codes[0] = OpCode{c.Tag, maxInt(i1, i2-n), i2, maxInt(j1, j2-n), j2}
401401
}
402402
if codes[len(codes)-1].Tag == 'e' {
403403
c := codes[len(codes)-1]
404404
i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
405-
codes[len(codes)-1] = OpCode{c.Tag, i1, min(i2, i1+n), j1, min(j2, j1+n)}
405+
codes[len(codes)-1] = OpCode{c.Tag, i1, minInt(i2, i1+n), j1, minInt(j2, j1+n)}
406406
}
407407
nn := n + n
408408
groups := [][]OpCode{}
@@ -412,11 +412,11 @@ func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode {
412412
// End the current group and start a new one whenever
413413
// there is a large range with no changes.
414414
if c.Tag == 'e' && i2-i1 > nn {
415-
group = append(group, OpCode{c.Tag, i1, min(i2, i1+n),
416-
j1, min(j2, j1+n)})
415+
group = append(group, OpCode{c.Tag, i1, minInt(i2, i1+n),
416+
j1, minInt(j2, j1+n)})
417417
groups = append(groups, group)
418418
group = []OpCode{}
419-
i1, j1 = max(i1, i2-n), max(j1, j2-n)
419+
i1, j1 = maxInt(i1, i2-n), maxInt(j1, j2-n)
420420
}
421421
group = append(group, OpCode{c.Tag, i1, i2, j1, j2})
422422
}

0 commit comments

Comments
 (0)