To print a value of type byte in Go using the fmt
package, you can use the %v
verb with the byte value as its corresponding argument.
main.go126 chars9 lines
In the above code, we declared a variable b
of type byte with a value of 65, which is the ASCII code for the uppercase letter 'A'. We then used the fmt.Printf
function with %v
verb and the b
variable as its corresponding argument to print the value of b
to the console.
Alternatively, you can also use the %d
verb to print the byte value as an integer.
main.go36 chars2 lines
gistlibby LogSnag