According to the doc, the flag '0' is ignored for strings
'0' pad with leading zeros rather than spaces; for numbers, this moves the padding after the sign; ignored for strings, byte slices and byte arrays
but the flag '0' is not ignored in below code. Is the doc wrong? Or do I misunderstand it?
package main
import "fmt"
func main() {
fmt.Printf("s", "abc")
// print 00abc
}
CodePudding user response:
Looks like you found a bug.
The source code resets the zero
flag only for -
(minus) flag. It is not modified neither for strings nor for any other type.
And the function that outputs a string doesn't reset the zero
flag either.