News for hackers. Stuff that matters.
Re:Go 1.18 by jchw on Wednesday March 16, 2022 @04:11PM (#30703428)
As far as I know, that’s only for interfaces, and it’s more like a union and not a sum type. I’m talking about sum types for structs, like Rust has with enum.

(I realize I’m replying ridiculous fast here, but I just happen to click over to Comments on the first minute. Dumb luck.)

Of course, I could just use Rust, but it’s much harder to make idiomatic Rust libraries than it is idiomatic Go libraries, and I think that fact stunts the ecosystem a bit.

Go may encourage you to use a map to an empty struct for a set, or a weird if statement syntax that contains a full statement instead of a more elegant looking match or for expression, but I find its little quirks to be manageable and without a terrible amount of consequence. Generics will probably bring some good, like the end of needing weird slice tricks, but I’m still concerned it won’t be overall worth it.

There are no comments on this comment yet.