Go 1.27 adds generic methods, but not on interfaces

Generic Methods in Go 1.27

Go 1.27 adds generic methods, but not on interfaces

Go 1.27, released August 2026, lets methods define their own type parameters without adding them to the receiving struct, removing a limitation since generics arrived in 1.18. The compiler's monomorphization clashes with runtime interface dispatch, so generic methods are allowed on concrete types but not interfaces, which is why the feature took years.

Ultimately, the Go team decided to separate generic methods from interfaces.
  1. dekdrop

    TIL

    > However, Go’s interface system works at runtime. The specific type of a value passed into an interface parameter is resolved while the program runs.

  2. throwaw12

    people working actively in "modern" Go codebases with generics, is it becoming like a Java/Spring kind of codebase?

    I understand why you might need generics, but I hate how Java ecosystem exploits it so much that, reading code becomes so difficult, because it was inherited from 10 levels of parent classes and in some cases Java Beans get created based on generic types and their parent classes are abstract classes.

  3. tancop

    > Go’s interface system works at runtime. The specific type of a value passed into an interface parameter is resolved while the program runs. This dynamic dispatch clashes with generics being resolved at compile time.

    What if the compiler generated both vtable and monomorphized variants for each method? Most calls would use the static version but places that need it like interface generics call the virtual method.

  4. DrCiphers

    So Go is becoming Java?

  5. EdSchouten

    Go is often thought of as a successor of C. C doesn't have methods, only global functions. From my perspective, Go added methods primarily so that you can use them in combination with interfaces. Given that interfaces don't support generic methods, I'm personally not convinced that this feature was worth adding.

More from this day

2026-08-20