Discriminated (type-safe) unions like ML and Haskell have are no problem for garbage collectors: you simply assign one ID to each variant of the union, and prefix the data with the ID corresponding to the variant in use.
You can simulate ML-style unions in Go with interfaces and downcasts, or the reflect package (basically like case classes in Scala, but without the exhaustiveness checking). Unfortunately, downcasts in Go (and interfaces generally) are slow.
You can simulate ML-style unions in Go with interfaces and downcasts, or the reflect package (basically like case classes in Scala, but without the exhaustiveness checking). Unfortunately, downcasts in Go (and interfaces generally) are slow.