I'd really love to be able to do:
type allowedTypes{
int64|float64|string
}
func Foo[T allowedTypes](arg T) {
switch t := arg {
case int64:
// something
case string:
// something completely different
}
}
As a way of having the type checker disallow other types from being passed so I don't have to return an error for incorrect types. I guess this would be the same as asking for typesets to be allowed in normal interfaces like:
func Foo(arg allowedTypes) {...}
Is there another way to achieve this? Is there a reason it is not possible?
Thanks!
Matt