Go 1.27 adds generic methods to concrete types
Methods can now define their own type parameters, ending a four-year limitation since generics' 2022 introduction.
What to know
- Go 1.27 enables methods on concrete types to declare their own type parameters, eliminating a design limitation present since generics' 2022 introduction.
- Generic methods remain excluded from interfaces due to incompatibility between compile-time monomorphization and runtime interface dispatch.
- The reflect package cannot detect generic methods, making them invisible to interfaces, validators, and ORMs relying on reflection.
“Methods can now define their own type parameters without adding them to the receiving struct.”
Dominik Honnef, Technical author · dominik.info blog
Dominik Honnef Technical authorGo team Language designers
The record 3 articles and posts · last 30 days
What people are saying 10 voices from 2 sites · verbatim
- Aug 21
-
Neither Go nor Java's generics is rich enough for the problems you describe. They give you the means to turn IntList into List<I>, but not into <L>Int or <L><I>.So I doubt the famous AbstractProxyBeanInterceptors are coming from an overuse of generics.
- Aug 20
-
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.
-
People like to blame Java for enterprise code, except they forget enterprise has been writing enterprisy code since Fortran, COBOL and Lisp days.I have found Spring like magic with pre-processor macros, sed and awk, in the glory days of Yourdon Structured Method and enterprisy C code.
-
I remember my coworkers having managed to write Java in pre-generics Go. The code had functions wrapped in functions wrapped in yet more functions, and interfaces only ever implemented by one type to replace the generics abuse. Life finds a way.
-
> inherited from 10 levels of parent classesThis is not (yet) a thing in Go. Go does not have classes and inheritance. Interface is more like duck-typing.
-
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…
-
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.
-
> 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…
-
H
Generic Methods in Go 1.27 L: https:// dominik.info/blog/go-generic-m ethods C: https:// news.ycombinator.com/item?id=4 9376211 posted on 2026.08.20 at 11:41:48 (c=0, p=4)
- Aug 19
-
H
Go 1.27: generic-методы, которых не видит reflect Go 1.27 (на момент написания rc3, финал обещают в августе) приносит generic-методы: метод наконец может объявить собственный тип-параметр. Взял golang:1.27rc3 в Docker и проверил, где у фичи границы. reflect новый метод не видит вообще, хотя go/types на том же типе показывает его в method set —…