Skip to content

Commit

Permalink
fix: add missing max util for go < 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Jan 24, 2025
1 parent a2c12f3 commit 19998d0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ansi/util_no121.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//go:build !go1.21
// +build !go1.21

package ansi

type ordered interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
~float32 | ~float64 |
~string
}

func max[T ordered](a, b T) T { //nolint:predeclared
if a > b {
return a
}
return b
}

0 comments on commit 19998d0

Please sign in to comment.