At the next StLGo meetup, he’ll show how his team used “go generate” and static analysis to bring union types into their server docs and schema validation, without changing the language, just how they use it.
17. type Ordered interface {
int | float32 | ~string
}
func GMin[T Ordered](x, y T) T {
if x < y {
return x
}
return y
}
18. —Golang Team
“…the new syntactic forms may only be used as
[generics] constraints. But it’s not hard to imagine how
explicitly type-constrained interfaces might be useful in
general.”