i was just trying about byte and i noticed a strange behaviour or may be i don’t fully understand it:
b := []byte{‘2’, ‘3’}
fmt.Println(b) // this print [50 51]
e := []byte(‘2’)
fmt.Println(e) // err: cannot convert ‘2’ rune to type []byte
so my conclusion is:
[]byte{} is a slice of byte that takes in only positive numbers while
[]byte() is a slice of byte that takes in only strings
mean while all this does is type conversion which convert int or string to uint8 (fmt.Printf("%T %T\n", b, ‘2’))
Am self taught, just wondering if am right or is there any other better explanation of []byte{} and []byte().