Get the latest tech news
Constraints in Go
Freedom is nothing without constraints, and Go’s generics gives us a powerful way to build polymorphic types and functions constrained by type sets . Let’s geek out.
But with more sophisticated interfaces, we might accidentally reduce the allowed type set to zero, and it’s helpful to know what this error message means so that we can fix the problem. The tests exercise this function by calling it with two values of a defined type MyInt, which has the required Greater method. Just like Equal, Greater takes arguments of some arbitrary type T, so we need an interface literal that can refer to T in its definition.
Or read this on Hacker News