Standard library / encoding/base32

encoding/base32.Encoding.AppendDecode()

Append decoded bytes while preserving the original destination prefix. Handle errors even when partial bytes were appended. Available in Go 1.22 and later. Expected stdout: 'id:Go\n'.

Formal Syntax & Structure

go syntaxgo
func (enc *Encoding) AppendDecode(dst, src []byte) ([]byte, 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

([]byte, error)

Decoded bytes (possibly partial) and error.

Working Example

Example Snippetgo
package main
import (  "encoding/base32"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  v, err := base32.StdEncoding.AppendDecode([]byte("id:"), []byte("I5XQ===="))  must(err)  fmt.Println(string(v))}
Go Reference