Added min function to utils to get min between two
comparable types (how isn't it in the STL?)
This commit is contained in:
parent
71c841bfef
commit
e2b0b09636
2
go.mod
2
go.mod
@ -1,3 +1,5 @@
|
||||
module maze-solver
|
||||
|
||||
go 1.20
|
||||
|
||||
require golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b
|
||||
|
2
go.sum
Normal file
2
go.sum
Normal file
@ -0,0 +1,2 @@
|
||||
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI=
|
||||
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
|
@ -1,6 +1,10 @@
|
||||
package utils
|
||||
|
||||
import "log"
|
||||
import (
|
||||
"log"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
|
||||
func Check(err error, msg string, args ...any) {
|
||||
if err != nil {
|
||||
@ -8,3 +12,10 @@ func Check(err error, msg string, args ...any) {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func Min[T constraints.Ordered](a, b T) T {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user