Hi, At work I have 3 different xml files I need to parse (different fields each), Because going from the xml bytes into a struct is pretty much the same for all 3 types, I thought I could do something like
var payload interface{} if kind == "A" { paylaod = TypeA{} } if kind == "B" { paylaod = TypeB{} } if kind == "C" { paylaod = TypeC{} } .... xml.Unmarshal([]byte(file), &payload) but this fails. It doesn't give me an error, but Unmarshal doesn't recognize the payload variable as the right (new) type. I created a very simple snippet here https://play.golang.org/p/QvVbM--Zdt produces: gen is type: main.X //<== see how the type is correct here xml gen is {One:} json gen is map[One:uno] gen is type: main.X //<== here I declared the variable with the right type and Unmarshal works xml gen is {One:uno} json gen is {One:uno} Hope this is enough information. Thanks Diego -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.