Hello,

I am working on code that formats strings. I have an issue with formatting 
the alternate form with zero padding of signed hexadecimals.

I have a format string like this: "%#07x", I would expect the zero padding 
to make sure the total width is 7. However, when I format the string using 
fmt.Sprintf I get the following results: 0x000002a which has the length of 
9 characters instead of the expected result: 0x0002a with the width of 7 
characters.

Example code: x := fmt.Sprintf("%#07x", 42) 
x will be equal to: 0x000002a

Example of python code that works as I would expect: result = 
"{:#07x}".format(42)
results will be equal to: 0x0002a

I am suspicious that this might be a bug where the 0x is not accounted in 
the width but maybe I am doing something wrong.
Thanks for any help :)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/05fcf363-098c-4e9b-be32-91b764ba36cdn%40googlegroups.com.

Reply via email to