Jabber requires a specific greeting:
<stream:stream
from='
im.example.com'
id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
to='
jul...@im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='
http://etherx.jabber.org/streams'>
I'm having a bitch of a time designing a struct to encode data. My
current iteration looks like this:
type StreamHeader struct {
XMLName xml.Name `xml:"stream stream"`
From string `xml:"from,attr"`
To string `xml:"to,attr"`
Version string `xml:"version,attr"`
Namespace string `xml:"xmlns,attr"`
XMLns string `xml:"xmlns stream,attr"`
}
Instantiated like so:
streamHeader := StreamHeader{
XMLName: xml.Name{
Space: "stream",
Local: "stream"},
From: jid.String(),
To: jid.GetDomain(),
Version: "1.0",
Namespace: "jabber:client",
XMLns: "
http://etherx.jabber.org/streams",
}
Which results in the following:
<stream xmlns="stream" from="
dco...@hammerfiber.com"
to="
hammerfiber.com" version="1.0" xmlns="jabber:client"
xmlns:_xmlns="xmlns"
_xmlns:stream="
http://etherx.jabber.org/streams"</stream>
Obviously, I have a fundamental misunderstanding of how the
Encoder/Marshaller works.
What's tripping me up the most right now is the requirement for multiple
xmlns attributes. Every time a new one appears, Go appends a _ to it.
There isn't enough documentation on this process. Can someone please
hit me with a clue bat?