Standard library / encoding/base32

encoding/base32.NewEncoder()

Stream Base32 output through a writer. Close the encoder to flush a partial five-byte group. Expected stdout: 'I5XQ====\n'.

Formal Syntax & Structure

go syntaxgo
func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser

Parameters & Attributes

NameTypeDescription
enc*EncodingBase32 alphabet and padding configuration.
wio.WriterWriter receiving encoded data.

Return Value

io.WriteCloser

Encoding writer; close it to flush remaining input.

Working Example

Example Snippetgo
package main
import (  "bytes"  "encoding/base32"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  var buf bytes.Buffer  w := base32.NewEncoder(base32.StdEncoding, &buf)  _, err := w.Write([]byte("G"))  must(err)  _, err = w.Write([]byte("o"))  must(err)  must(w.Close())  fmt.Println(buf.String())}
Go Reference