4 ms·
Unfortunately we have to wait. Generics handle simple cases well, but have issues with more complex edge cases. Every go release is improving Generics. 1.19 has
by gregwebs 4y ago
Unfortunately we have to wait. Generics handle simple cases well, but have issues with more complex edge cases. Every go release is improving Generics. 1.19 has a performance regression that will be fixed in 1.20.
Library authors want to support old go versions, and the library usage of Generics might not work on that older version.
I just started using generics because I wanted a couple release cycles for issues to be shaken out. I would suggest to most library authors to wait until 1.20 is released before using generics, and if you are doing anything slightly sophisticated to make sure you have a CI that builds with older versions of Go.
If you are writing application code, then go ahead and use generics, but generics are usually most useful for libraries.
I was recently able to fork a library for better error handling in Go and make a version similar to the try proposal. This library wouldn't have been possible without generics: https://github.com/gregwebs/try https://github.com/gregwebs/try