Standard library / encoding/hex
encoding/hex.NewDecoder()
Wraps a reader to decode hexadecimal text incrementally. Expected stdout: 'Go\n'.
Formal Syntax & Structure
go syntaxgo
func NewDecoder(r io.Reader) io.ReaderParameters & Attributes
| Name | Type | Description |
|---|---|---|
| r | io.Reader | Input stream. |
Return Value
io.Reader
Reader wrapping the input.
Working Example
Example Snippetgo
package main
import ( "encoding/hex" "fmt" "io" "strings")
func must(e error) { if e != nil { panic(e) }}
func main() { p, e := io.ReadAll(hex.NewDecoder(strings.NewReader("476f"))) must(e) fmt.Println(string(p))}