]> Cypherpunks repositories - gostls13.git/commitdiff
fmt: document width and flags a bit more
authorRuss Cox <rsc@golang.org>
Sat, 22 Dec 2012 18:36:39 +0000 (13:36 -0500)
committerRuss Cox <rsc@golang.org>
Sat, 22 Dec 2012 18:36:39 +0000 (13:36 -0500)
Fixes #4581.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7000052

src/pkg/fmt/doc.go

index ff947b68a746e958b5e3bce6932c02ff1a2e1d09..2c925a4228308df466a9c096b24143935fa4c511 100644 (file)
        The default precision for %e and %f is 6; for %g it is the smallest
        number of digits necessary to identify the value uniquely.
 
-       For strings, width is the minimum number of characters to output,
-       padding with spaces if necessary, and precision is the maximum
-       number of characters to output, truncating if necessary.
+       For most values, width is the minimum number of characters to output,
+       padding the formatted form with spaces if necessary.
+       For strings, precision is the maximum number of characters to output,
+       truncating if necessary.
 
        Other flags:
                +       always print a sign for numeric values;
                        write e.g. U+0078 'x' if the character is printable for %U (%#U).
                ' '     (space) leave a space for elided sign in numbers (% d);
                        put spaces between bytes printing strings or slices in hex (% x, % X)
-               0       pad with leading zeros rather than spaces
+               0       pad with leading zeros rather than spaces;
+                       for numbers, this moves the padding after the sign
+
+       Flags are ignored by verbs that do not expect them.
+       For example there is no alternate decimal format, so %#d and %d
+       behave identically.
 
        For each Printf-like function, there is also a Print function
        that takes no format and is equivalent to saying %v for every