Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
4e221896
Commit
4e221896
authored
Jan 26, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fmt/doc: define width and precision for strings.
R=rsc CC=golang-dev
https://golang.org/cl/4061045
parent
a64e6322
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
src/pkg/fmt/doc.go
src/pkg/fmt/doc.go
+14
-9
No files found.
src/pkg/fmt/doc.go
View file @
4e221896
...
...
@@ -26,7 +26,7 @@
%o base 8
%x base 16, with lower-case letters for a-f
%X base 16, with upper-case letters for A-F
%U
u
nicode format: U+1234; same as "U+%x" with 4 digits default
%U
U
nicode format: U+1234; same as "U+%x" with 4 digits default
Floating-point and complex constituents:
%e scientific notation, e.g. -1234.456e+78
%E scientific notation, e.g. -1234.456E+78
...
...
@@ -44,14 +44,19 @@
There is no 'u' flag. Integers are printed unsigned if they have unsigned type.
Similarly, there is no need to specify the size of the operand (int8, int64).
For numeric values, the width and precision flags control
formatting; width sets the width of the field, precision the
number of places after the decimal, if appropriate. The
format %6.2f prints 123.45. The width of a field is the number
of Unicode code points in the string. This differs from C's printf where
the field width is the number of bytes. Either or both of the
flags may be replaced with the character '*', causing their values
to be obtained from the next operand, which must be of type int.
The width and precision control formatting and are in units of Unicode
code points. (This differs from C's printf where the units are numbers
of bytes.) Either or both of the flags may be replaced with the
character '*', causing their values to be obtained from the next
operand, which must be of type int.
For numeric values, width sets the width of the field and precision
sets the number of places after the decimal, if appropriate. For
example, the format %6.2f prints 123.45.
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.
Other flags:
+ always print a sign for numeric values
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment