Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
fmt: no padding is applied for "%x" or "%X" #10465
go version devel +9402e49 Wed Apr 15 05:03:42 2015 +0000 darwin/amd64
testcases to see no padding is applied to strings and byte slices:
Also strings and byte slice then as far as i understood need to be handled with differing padding logic as the strings needs to be padded as a whole not hex by hex.
would this be the intended behavior?
Its a bit unclear now to me how and if both of these statements should be applied to the examples:
some issues i encountered while reintroducing the padding with the changes of #10430 in mind:
if padding is applied on a per element basis precision should likely too:
However there are existing test cases that apply it to the whole slice:
I think there are at least 3 options that can be implemented to format byte slices while correcting the padding:
Also should change the doc "' ' (space) leave a space for elided sign in numbers (% d);
If there should still be spaces between elements then specifying "% x" would have the (likely unintended) side effect of introducing spaces between elements and adding a space for each byte element in place of sign at the same time.
There are some things that need to be thought about here and there are also conflicts in the documentation. For example, it says that "% x" puts spaces between the elements, which implies the first element should not have a space before it, and I believe that is correct and desired behavior, while on the other hand it says the format applies to all elements, which presumably applies to the first.
This is not an urgent issue and resolving it may break some things, so I am deferring it until 1.6.
The documentation says:
The behavior is consistent with that sentence: The entire item is padded, while the 0 and space flags do apply elementwise, as one would expect.