Standard library / encoding/base32

encoding/base32.NewEncoding()

Construct a custom 32-byte alphabet with default padding. Invalid or duplicate alphabet bytes cause a panic; use the predefined encodings for interoperability. Expected stdout: 'I5XQ====\n'.

Formal Syntax & Structure

go syntaxgo
func NewEncoding(encoder string) *Encoding

Parameters & Attributes

NameTypeDescription
encoderstringExactly 32 distinct alphabet bytes, excluding newline, carriage return and default padding.

Return Value

*Encoding

Base32 alphabet and padding configuration.

Working Example

Example Snippetgo
package main
import (  "encoding/base32"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  enc := base32.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")  fmt.Println(enc.EncodeToString([]byte("Go")))}
Go Reference