如何在Golang中将XML编码UTF-16转换为UTF-8

My code as below

xml_string = `<?xml version="1.0" encoding="UTF-16"?><a></a>`
var req Request

text := strings.NewReader(string(response))
nr, _ = charset.NewReaderLabel("utf-16", text)
decoder := xml.NewDecoder(nr)
err := decoder.Decode(&req)

By the way I am getting EOF error and nil decoded response. Not seem to make it work.

import "unicode/utf16"
import "unicode/utf8"
import "bytes"

func DecodeUTF16(b []byte) (string, error) {

    if len(b)%2 != 0 {
        return "", fmt.Errorf("Must have even length byte slice")
    }

    u16s := make([]uint16, 1)

    ret := &bytes.Buffer{}

    b8buf := make([]byte, 4)

    lb := len(b)
    for i := 0; i < lb; i += 2 {
        u16s[0] = uint16(b[i]) + (uint16(b[i+1]) << 8)
        r := utf16.Decode(u16s)
        n := utf8.EncodeRune(b8buf, r[0])
        ret.Write(b8buf[:n])
    }

    return ret.String(), nil
}

Hope This helps u. ^_^