Goldziher / go-utils

Simple and performant utilies using Go generics inspired by JavaScript and Python
https://goldziher.github.io/go-utils/
MIT License
46 stars 13 forks source link

Use constraints package to define 'number' type. Enable calling sum o… #5

Closed kacperwnuk closed 2 years ago

kacperwnuk commented 2 years ago

Currently I cannot call sliceutils.Sum() with user-defined type. To fix this issue I suggest using constraints package. Alternatively, if You do not want to import additional module, 'number' interface can be fixed by using '~' type numbers interface { ~int | ... }

Have a nice day!

Goldziher commented 2 years ago

Great, thanks for your contribution! I will release this promptly.