Almost.
What you're dealing with is a typical set of headers of a so-called
"MIME-formatted" e-mail message followed by its body. The usual set of
headers is missing (those 'From', 'To' etc) and that's why it looks
strange.
So you parse it like a regular mail message using the net/mail package
and then base64-decode its body.
The program (playground link is [1])
----------------8<----------------
package main
import (
"bytes"
"encoding/base64"
"fmt"
"io"
"net/mail"
"strings"
)
const s = `MIME-Version: 1.0
content-type: text/xml
content-transfer-encoding: base64
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPD94bWwtc3R5bGVzaGVldCB0
`
func main() {
sr := strings.NewReader(s)
msg, err := mail.ReadMessage(sr)
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", msg.Header)
var buf bytes.Buffer
dec := base64.NewDecoder(base64.StdEncoding, msg.Body)
_, err = io.Copy(&buf, dec)
if err != nil {
panic(err)
}
fmt.Println(buf.String())
}
----------------8<----------------
outputs:
| mail.Header{"Content-Type":[]string{"text/xml"}, "Content-Transfer-Encoding":[]string{"base64"}, "Mime-Version": []string{"1.0"}}
| <?xml version="1.0" encoding="UTF-8"?>
| <?xml-stylesheet t
Which is indeed base64-encoded XML document.
As shown, you can (should?) inspect the parsed headers to know which
content type the decoded document really is (say, if in the future your
source would sent Content-Type: text/json you'll be better prepared for
this).
1.
https://play.golang.org/p/lOKAAfQRs8