Go FAQ: The Pipe Operator In Generics Is Not A Sum Type

from blog iRi, | ↗ original
An increasingly-frequently asked question in the Go subreddit is some variant of: “I have this code but it isn’t doing what I expect it to do.” type MyStruct struct { // definition } type OtherStruct struct { // definition } type MySumType interface { MyStruct | OtherStruct } func main() { myStruct := MyStruct{...} printVal(myStruct) } func...