Encoding.DecodeString in Go

Posted by GoDoc
Public (Editable by Users)

DecodeString returns the bytes represented by the base64 string s.

Go
Edit
package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	str := "c29tZSBkYXRhIHdpdGggACBhbmQg77u/"
	data, err := base64.StdEncoding.DecodeString(str)
	if err != nil {
		fmt.Println("error:", err)
		return
	}
	fmt.Printf("%q\n", data)
}