You’re quoting the help for %x for strings and byte slices. For integers it 
simply says "base 16, with lower-case letters for a-f” and thus behaves like 
any other number base usually does. In this case, you want “%02x”.

//jb

On 21 Feb 2018, at 12:06, David Renne 
<davidre...@gmail.com<mailto:davidre...@gmail.com>> wrote:

https://play.golang.org/p/XZimA47p9qM

Why isnt this formatted with two bytes below 10 and is merely 0-9 instead of 
00, 01, 02 etc etc with a left padded zero?

The documentation of %x for sprintf made me think that this would keep a left 
padded zero on my string for 0-9, so I merely abstracted my sprintf to check if 
it's lower than 10 and then pad it to make it look like a proper mac address.  
I would love to come up with some better verbiage for the description in the 
documentation for 0-9 so people arent surprised and need to left pad it like I 
had to for a mac address


%x      base 16, lower-case, two characters per byte




--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
golang-nuts+unsubscr...@googlegroups.com<mailto:golang-nuts+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to