Answers for "printing byte slice to hexadecimal string in golang"

Go
1

printing byte slice to hexadecimal string in golang

// printBytesToHex methods prints byte slice to hexadecimal string in golang
func printBytesToHex() {
	bytes := []byte("printing bytes to hexadecimal") // byte slice
  fmt.Printf("%v\n", bytes) // output: [112 114 105 110 116 105 110 103 32 98 121 116 101 115 32 116 111 32 104 101 120 97 100 101 99 105 109 97 108]
  fmt.Printf("%x\n", bytes) // output: 7072696e74696e6720627974657320746f2068657861646563696d616c
}
Posted by: Guest on July-03-2021

Browse Popular Code Answers by Language