Base64 encoding
Context
Section titled “Context”The encoding/base64 package encodes and decodes Base64. Use StdEncoding for standard Base64, URLEncoding for URL‑safe.
Example
Section titled “Example”Encode and decode a string.
Code example
Section titled “Code example”package main
import ( "encoding/base64" "fmt")
func main() { data := []byte("hello world") encoded := base64.StdEncoding.EncodeToString(data) fmt.Println(encoded)
decoded, _ := base64.StdEncoding.DecodeString(encoded) fmt.Println(string(decoded))}Output
Section titled “Output”aGVsbG8gd29ybGQ=hello world