]> Cypherpunks repositories - gostls13.git/commit
fmt: restore padding for %x on byte slices and strings
authorRob Pike <r@golang.org>
Sat, 27 Jun 2015 01:07:30 +0000 (11:07 +1000)
committerRob Pike <r@golang.org>
Mon, 29 Jun 2015 07:17:23 +0000 (07:17 +0000)
commita76c1a5c7fb704e5658bbbe9f27b4301b86bfd80
tree75dafa9908fb9caf752c1b27cb24ccda6502c985
parentc97e73d8497f61b61299e5d2d371ef672d0c596d
fmt: restore padding for %x on byte slices and strings

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/11600
Reviewed-by: Russ Cox <rsc@golang.org>
src/fmt/doc.go
src/fmt/fmt_test.go
src/fmt/format.go