RawStdEncoding
, as its name suggests, accepts "raw" base64 encoded strings. The string you used on the other hand is padded with 2 "="s. try removing them and you should get no errors:
data, err := base64.RawStdEncoding.DecodeString("//Py+vX7suTx8A") // no paddings
if err != nil {
fmt.Printf("err: %v\n", err)
}
fmt.Printf("data: %v\n", data)
And as @JimB said, if you want to decode padded strings anyway, just use base64.StdEncoding
with the padded version.
data, err := base64.StdEncoding.DecodeString("//Py+vX7suTx8A==")
if err != nil {
fmt.Printf("err: %v\n", err)
}
fmt.Printf("data: %v\n", data)