Your code successfully captures the faultstring
and faultcode
, but then unintentionally overwrites it with xml.CharData
containing the whitespace between tags.
Here is a fixed version: http://play.golang.org/p/s1aFFYtwcX . Comment out line 52 to see the failure mode.
Alternatively, you can use encoding/xml Unmarshal
to parse the XML directly into a struct. See http://play.golang.org/p/lOsZRUJ63B