homeprojectsmetronome
githubblog

go-tuple is a generic tuple implementation for Go 1.18+.

As a developer coming from C++ and Python, having no generics features was a huge pain point to me when transitioning to Go. When Go 1.18 was in beta, I was excited to go try it out.

I chose tuples, their absent from the Go language to begin with is a bit baffling, and it seemed easy enough.

It ended up being a good introduction to generics and their limitations. I wrote a more detailed blog about the implemnetation journey.

In a a true Go fashion, it doesn't support variadic generic parameters, which means I ended up needing a type for each tuple size. I was able to write a go template file that generates tuple types code according to the number of values required, which is used in order to power the package.