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 230 views
3 answers 429 views
1 answer 203 views
3 answers 150 views
1 answer 127 views
1 answer 267 views
...