-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fmt: Printf does not zero pad. #11422
Comments
Confusing example - there's no need to involve math/big. But you're right, tip appears to be wrong. On the playground: http://play.golang.org/p/pnJg1u_z2K:
we get:
On tip we get:
|
Given 1.4 does this: 00ab while tip does this: ab Both are wrong. The root bug is original; the change in behavior applies because of a fix at tip that, coincidentally, propagates the original bug. The correct output is 00ab I will fix. |
CL https://golang.org/cl/11600 mentions this issue. |
I was mistaken; there has been a regression from 1.4, where the output was correct: 00ab At issue is whether the width and flags apply elementwise or to the whole, and the answer is: width: whole; flags, elementwise. And this must be consistent for []byte and for string when using this format. The CL listed here restores and explains the behavior. |
The following code does not 0-pad on tip. It does work expected with 1.4.2, see http://play.golang.org/p/A7oXWwj5s_
$ go version
go version devel +a1cc84f Fri Jun 26 09:53:36 2015 +0000 openbsd/amd64
The text was updated successfully, but these errors were encountered: