Go has no unions. But unions are necessary in many places. XML makes excessive use of unions or choice types. I tried to find out, which is the preferred way to work around
I think this amount of code might be reduced, e.g. I personally do not think that safeguarding type Misc
against containing "illegal" stuff is really helpful: A simple type Misc interface{}
would do, or?
With that you spare the constructors and all the Is{Comment,ProcessingInstruction,WhiteSpace}
methods boil down to a type switch
switch m := misc.(type) {
Comment: fmt.Println(m)
...
default: panic()
}
Thats what package encoding/xml does with Token.