I found a working version meantime. // Max returns the bigger value between two numbers. func Max[T constraints.Ordered](x, y T) T { if x > y { return x } return y }
// Abs returns the absolut value of x. func Abs[T constraints.Signed | constraints.Float](x T) T { if x < 0 { return -x } return x } On Saturday, March 19, 2022 at 12:22:39 PM UTC+2 Gergely Födémesi wrote: > some details: https://github.com/golang/go/issues/48918 > > On 3/18/22, Endre Simo <esi...@gmail.com> wrote: > > Now that generics are officially supported, I was checking in the Go > source > > > > if there are some generic implementation of utility methods like Abs, > Min, > > Max etc, but I couldn't find it other than this > > proposal https://github.com/golang/go/discussions/48287. > > > > Anyone knows if something related has been adopted and implemented in Go > > 1.18? > > > > -- > > You received this message because you are subscribed to the Google Groups > > "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to golang-nuts...@googlegroups.com. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/golang-nuts/e930b89a-0ba6-46f5-b3ec-7aeb26d8acf9n%40googlegroups.com > . > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/baa8d4bd-048f-4f27-a53d-7a3263b2ed2dn%40googlegroups.com.