4 ms·
For me this was something I missed when I started with Go about a year ago (at that point my brain was still filled with years of C# dogma). I was not very fami
by exch 16y ago
For me this was something I missed when I started with Go about a year ago (at that point my brain was still filled with years of C# dogma). I was not very familiar with Go's own way of doing things back then. Go may seem familiar at first glance, but there are some peculiar little differences which offer new and novel ways of dealing with a problem. Unfortunately these are very difficult to explain to someone who is not already familiar with the language.
At this point I don't miss generics at all. The benefit they would give me are marginal enough to not consider it a vital component.
I've found that when you become proficient in Go, you will write different code that does not really require generics to be present. At least 99% of the time.
Having said that, I am still hoping that we might one day get unions. Unfortunately there is little hope of that at this point. It has been considered, but they would have to be type-safe in order not to circumvent Go's type system. And doing so, would differentiate them very little from Go's existing 'interface{}' type. There is a small benefit to unions, but apparently not big enough to warrant implementing them.
As far as generics go, they are not out of the question. The problem so far has been that nobody has yet offered a generics proposal that doesn't partially or completely mess up the language and generally make things more difficult for everyone.