Standard library / encoding/hex
encoding/hex.AppendDecode()
Appends decoded bytes to existing data. An invalid suffix can leave a valid prefix in the result. Expected stdout: '!Go\n'.
Formal Syntax & Structure
go syntaxgo
func AppendDecode(dst, src []byte) ([]byte, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| dst | []byte | Destination byte slice; append APIs preserve its existing prefix. |
| src | []byte | Source 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/hex" "fmt")
func must(e error) { if e != nil { panic(e) }}
func main() { p, e := hex.AppendDecode([]byte("!"), []byte("476f")); must(e); fmt.Println(string(p)) }