fmt package documentation

138 views
Skip to first unread message

Allen Tracht

unread,
Jul 4, 2022, 8:28:33 PM7/4/22
to golang-nuts
The documentation of the formatting language inhttps://cs.opensource.google/go/go/+/master:src/fmt/doc.go;l=132 doesn't render the "other flags" section well. It all runs together:
source: ----
Other flags:
   '+'    always print a sign for numeric values;
       guarantee ASCII-only output for %q (%+q)
   '-'    pad with spaces on the right rather than the left (left-justify the field)
   '#'    alternate format: add leading 0b for binary (%#b), 0 for octal (%#o),
       0x or 0X for hex (%#x or %#X); suppress 0x for %p (%#p);
       for %q, print a raw (backquoted) string if strconv.CanBackquote
       returns true;
       always print a decimal point for %e, %E, %f, %F, %g and %G;
       do not remove trailing zeros for %g and %G;
       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;
       for numbers, this moves the padding after the sign;
       ignored for strings, byte slices and byte arrays
----
rendered-----
Other flags:
  • always print a sign for numeric values; guarantee ASCII-only output for %q (%+q)
  • pad with spaces on the right rather than the left (left-justify the field) # alternate format: add leading 0b for binary (%#b), 0 for octal (%#o), 0x or 0X for hex (%#x or %#X); suppress 0x for %p (%#p); for %q, print a raw (backquoted) string if strconv.CanBackquote returns true; always print a decimal point for %e, %E, %f, %F, %g and %G; do not remove trailing zeros for %g and %G; 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; for numbers, this moves the padding after the sign
-----

Maybe there's already an issue open for this: it's hard to query for src/fmt/doc.go: the terms are too common.

-- Allen

ben...@gmail.com

unread,
Jul 5, 2022, 5:47:55 PM7/5/22
to golang-nuts
At the default URL https://pkg.go.dev/fmt the same thing happens for me too. However, at https://pkg.go.dev/fmt@master it formats correctly (pre-formatted block like in the source). So I assume this has been fixed and the default will be updated soon (when 1.19 comes out?).

-Ben

peterGo

unread,
Jul 5, 2022, 7:55:56 PM7/5/22
to golang-nuts
Other flags is fixed in Go 1.19: https://pkg.go.dev/f...@go1.19beta1

Peter
Reply all
Reply to author
Forward
0 new messages