Not a hard question. It’s sum types! (Or enums, tagged unions, or whatever you want to call them).
While you’re at it, with sum types, you can replace this stupid nil with an optional type. Also, you can replace the stupid error handling with an either/result type. Then you can add a keyword to return early if it’s left/err. Then you have Swift or Rust.
Go was my favorite mainstream language for GSD for years last decade. I was happy using it.
I came off a development ‘extended holiday’ by jumping into Rust dev over the last few months. I think I’m less happy. Though my software is arguably functionally better, even if I fucking despise the way it looks and reads.
Maybe I just never realized I’m a grug brained developer at heart.
I do hate the way enums are in Go. It’s just barely better than using a
string
orint
in most cases.