Open
Description
This is a proposal for sum types, also known as discriminated unions. Sum types in Go should essentially act like interfaces, except that:
- they are value types, like structs
- the types contained in them are fixed at compile-time
Sum types can be matched with a switch statement. The compiler checks that all variants are matched. Inside the arms of the switch statement, the value can be used as if it is of the variant that was matched.