Golang encoding/hex.Dumper() function example
package encoding/hex
Dumper returns a WriteCloser that writes a hex dump of all written data to w (1st parameter). The format of the dump matches the output of
hexdump -C
on the command line.
Golang encoding/hex.Dumper() function usage example
package main
import (
"bytes"
"encoding/hex"
"fmt"
)
func main() {
var buff bytes.Buffer
str := []byte("abcd")
dumper := hex.Dumper(&buff)
dumper.Write(str)
dumper.Close()
fmt.Println(string(buff.Bytes()))
}
Output :
00000000 61 62 63 64 |abcd|
Reference :
Advertisement
Something interesting
Tutorials
+12.2k Golang : calculate elapsed run time
+8.6k Golang : Progress bar with ∎ character
+30.6k Golang : Remove characters from string example
+21.1k Golang : Get password from console input without echo or masked
+8.9k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+6.3k Golang : Extract sub-strings
+9.7k Golang : Detect number of active displays and the display's resolution
+11.9k Golang : Convert decimal number(integer) to IPv4 address
+8.2k Prevent Write failed: Broken pipe problem during ssh session with screen command
+8.7k Golang : Find duplicate files with filepath.Walk
+10.6k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+5.9k Golang : Denco multiplexer example