Standard library / encoding/hex

encoding/hex.Dumper()

Creates a streaming hex dump writer. Close to finish the last line. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func Dumper(w io.Writer) io.WriteCloser

Parameters & Attributes

NameTypeDescription
wio.WriterOutput stream.

Return Value

io.WriteCloser

Writer that must be closed to finish the stream.

Working Example

Example Snippetgo
package main
import (  "bytes"  "encoding/hex"  "fmt"  "strings")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  var out bytes.Buffer  w := hex.Dumper(&out)  _, e := w.Write([]byte("Go"))  must(e)  must(w.Close())  fmt.Println(strings.Contains(out.String(), "47 6f"))}
Go Reference