Standard library / encoding/base32

encoding/base32.Encoding.Decode()

Decode into a caller-provided byte buffer of sufficient size. Use the actual count returned; malformed data may produce a valid prefix plus an error. CR and LF are ignored. Expected stdout: 'Go 2\n'.

Formal Syntax & Structure

go syntaxgo
func (enc *Encoding) Decode(dst, src []byte) (n int, err error)

Parameters & Attributes

NameTypeDescription
dst[]byteDestination byte slice; provide enough capacity for the operation or use an append API.
src[]byteInput bytes in the format expected by the operation.

Return Value

(n int, err error)

Bytes written and error.

Working Example

Example Snippetgo
package main
import (  "encoding/base32"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  e := base32.StdEncoding  src := []byte("I5XQ====")  dst := make([]byte, e.DecodedLen(len(src)))  n, err := e.Decode(dst, src)  must(err)  fmt.Println(string(dst[:n]), n)}
Go Reference