• Rob Pike's avatar
    fmt: restore padding for %x on byte slices and strings · a76c1a5c
    Rob Pike authored
    Also improve the documentation. A prior fix in this release
    changed the properties for empty strings and slices, incorrectly.
    Previous behavior is now restored and better documented.
    
    Add lots of tests.
    
    The behavior is that when using a string-like format (%s %q %x %X)
    a byte slice is equivalent to a string, and printed as a unit. The padding
    applies to the entire object. (The space and sharp flags apply
    elementwise.)
    
    Fixes #11422.
    Fixes #10430.
    
    Change-Id: I758f0521caf71630437e43990ec6d6c9a92655e3
    Reviewed-on: https://go-review.googlesource.com/11600Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    a76c1a5c
format.go 12.4 KB