How to use the fmt package to print a value of type byte in Go

1 Answer

0 votes
package main

import "fmt"

func main() {
	var ch byte = 'a'
	
	fmt.Printf("%T\n", ch)
	fmt.Printf("%v\n", ch)
	fmt.Printf("%c\n", ch)
	fmt.Printf("%b\n", ch)
	fmt.Printf("%x\n", ch)
	fmt.Printf("%#x\n", ch)
	fmt.Printf("%U\n", ch)
	
}
 
 
/*
run:
 
uint8
97
a
1100001
61
0x61
0X61
U+0061
   
*/

 



answered Dec 23, 2024 by avibootz

Related questions

1 answer 222 views
3 answers 406 views
1 answer 194 views
3 answers 146 views
1 answer 123 views
1 answer 261 views
...