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
+19.5k Golang : How to Set or Add Header http.ResponseWriter?
+18k Golang : How to log each HTTP request to your web server?
+13.1k Golang : List objects in AWS S3 bucket
+7k Golang : Find the shortest line of text example
+11.9k Golang : Setup API server or gateway with Caddy and http.ListenAndServe() function example
+24.1k Golang : Upload to S3 with official aws-sdk-go package
+10.6k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+6.3k Golang : Extract sub-strings
+5.8k Unix/Linux : Get reboot history or check when was the last reboot date
+7.1k Golang : Get Alexa ranking data example
+16.6k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file