Standard library / encoding/base64

encoding/base64.NewDecoder()

Wraps a reader to decode Base64 as a stream. Read errors may follow valid prefix bytes. Expected stdout: 'Go\n'.

Formal Syntax & Structure

go syntaxgo
func NewDecoder(enc *Encoding, r io.Reader) io.Reader

Parameters & Attributes

NameTypeDescription
enc*EncodingBase64 encoding configuration.
rio.ReaderInput stream.

Return Value

io.Reader

Reader wrapping the input.

Working Example

Example Snippetgo
package main
import (  "encoding/base64"  "fmt"  "io"  "strings")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  r := base64.NewDecoder(base64.StdEncoding, strings.NewReader("R28="))  p, e := io.ReadAll(r)  must(e)  fmt.Println(string(p))}
Go Reference