Golang encoding/hex.Dump() function example

package encoding/hex

Dump returns a string that contains a hex dump of the given data. The format of the hex dump matches the output of hexdump -C on the command line.

Golang encoding/hex.Dump() function usage example

 package main

 import (
 "encoding/hex"
 "fmt"
 )

 func main() {
 str := []byte("abcd")

 fmt.Println(hex.Dump(str))
 }

Output :

00000000 61 62 63 64 |abcd|

Reference :

http://golang.org/pkg/encoding/hex/#Dump

Advertisement