Good union types in Go would probably need types without a zero value

The author discusses the importance of good union types in Go, emphasizing the need for types without a zero value to prevent null values. While union types are often associated with implementing option types to handle null values, the author points out that union and option types alone do not fully protect against null values. They argue that non-nullable types are crucial for guaranteeing proper values extracted from error-free results. The author suggests that introducing types without a zero value could make Result and similar types more useful in Go, but acknowledges that zero values are deeply ingrained in Go’s design, making powerful union types unlikely in the language’s future.

https://utcc.utoronto.ca/~cks/space/blog/programming/GoUnionTypesAndZeroValues

To top