i := 255 h := fmt.Sprintf("%x", i) fmt.Printf("Hex conv of '%d' is '%s'\n", i, h) h = fmt.Sprintf("%X", i) fmt.Printf("HEX conv of '%d' is '%s'\n", i, h)
Hex conv of '255' is 'ff' HEX conv of '255' is 'FF'
"Hex" isn't a real thing. You can use a hexadecimal representation of a number, but there's no difference between 0xFF and 255. More info on that can be found in the docs which point out you can use 0xff to define an integer constant 255! As you mention, if you're trying to find the hexadecimal representation of an integer you could use strconv