----- FUNCTION THAT EXCEPTS GENERICS ----- This generic type parameter is capital, between square brackets and has a rule for what data it will except called a constraint any : anything comparable : Anything that supports == More Constraints : pkg.go.dev/golang.org/x/exp/constraints You can also def
| 112 | // You can also define what is excepted like this |
| 113 | // Define that my generic must be an int or float64 |
| 114 | type MyConstraint interface { |
| 115 | int | float64 |
| 116 | } |
| 117 | |
| 118 | func getSumGen[T MyConstraint](x T, y T) T { |
| 119 | return x + y |
nothing calls this directly
no outgoing calls
no test coverage detected