代码实例:
package main
import (
"encoding/base64"
"io/ioutil"
"strings"
)
var (
// base 64 数据
data = `//MoxAAL0EJ9f00YAgsIAFW28BuBdxzn9vQrSJQMLB+TC9wsc9rrNcok4c9393sb/7enbW9Y/q/T1f2GlQ1xa//rf+Xvldb///MoxAsPiXqoAYVYAGvfRKK3mf/71iWfMTdEoP//kxNc4xgrEeDo6Df//hnsZTDc3Tsew9/k+Vff//6iAIf/9Kr///5xDs0///MoxAcOOY7QAcFAANy+5fhPpFFxYweSWL0D4uKB2DY0XpBRH8v+N+05H4pLUgomtPcu4+iB8////vLoNHMhu89D/s9wEFP///MoxAkOMYLoyimGlP+wYg3bJU+sWl/6nHSIWEKKeL2WMqYweZfwv//7B3wmYZ0AuUVQsdQe///vVTGqqTuNx/QRKwEuMCe///MoxAsPyV7kymrGlP0x/Rb/xwCBJqdn6dQZhsYrIne0jNtVJmjKXlS/n91K9W4EIg4JxQILT//597XvTKPYLIWqb6yjIYBe//MoxAYOoYbQAJNKlA+eX1okmFeGuyOtpkItB1JKejHagaov+JG16yiz/9v8odVkep1YeFpBCeZ/+FK6GuU11sFq/q/vw3/3//MoxAYNMK8uX0gQAvwBP/OUex1gBSD0LEUkwFQfHrH+FE/4UT6g4zkv+Ip6VAQdkg7//7GywNHhK5Wu6+zpj0AbHgpCPH57//MoxAwO2R7UAY1QAIDAXBJ/lBYGhf9zDGKGHnJ/MYwxh+eg/IzvqOQ/f5QzLmutn4E5MZzN/9IIfLBVVfqUkkZD2BDkgUXp//MoxAsMUOrcAc1AAFTqOhbRhDE3f+GYQQhOCMiv/Vhowyb/UoeocesNB3yz/////55KFQKBIobMABgB+rPUIhKaHYf52XrX//MoxBQNKMryXisScKmVYKg9g3EdHT/3FmQyWQF0aBChWaBrkwv//////+qVUgLAq1XLQBQB/VXKG9wpB7Nw0e9GuatzmtG4//MoxBoM+NMCXhLYcoMXEy8TFrT2PW1mIjEx2/qCgOfp///////XG1aURj22GwH1UjMKEiJRwkPFQBfQ2ttHKA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AAANIAAAAAFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//MoxMQAAANIAAAAAFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//MoxMQAAANIAAAAAFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV`
)
func main() {
reader := strings.NewReader(data)
decoder := base64.NewDecoder(base64.StdEncoding, reader)
// 以流式解码
buf := make([]byte, 2)
// 保存解码后的数据
dst := ``
for {
n, err := decoder.Read(buf)
if n == 0 || err != nil {
break
}
dst += string(buf[:n])
}
ioutil.WriteFile(`解码完成的音乐文件.mp3`, []byte(dst), 0666)
}