Standard library / encoding/base64

encoding/base64.Encoding.AppendDecode()

Appends decoded bytes to a destination, preserving the prefix; malformed input can return partial bytes and an error. Expected stdout: '!Go\n'.

Formal Syntax & Structure

go syntaxgo
func (enc *Encoding) AppendDecode(dst, src []byte) ([]byte, error)

Parameters & Attributes

NameTypeDescription
dst[]byteDestination byte slice; append APIs preserve its existing prefix.
src[]byteSource bytes to encode or decode.

Return Value

([]byte, error)

Resulting bytes (possibly partial for decoding) and error.

Working Example

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