[Go] Decode a Base64 string

Created on November 30, 2026

Use base64.StdEncoding.DecodeString to decode a string that uses the standard Base64 alphabet. It returns the decoded bytes and an error if the input is invalid.

package main

import (
    "encoding/base64"
    "fmt"
)

func main() {
    strBytes, err := base64.StdEncoding.DecodeString("ZHVtbXk=")
    if err != nil {
        panic(err.Error())
    }
    fmt.Print(string(strBytes))
}

Output

dummy
Go