Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
8f2bf201
Commit
8f2bf201
authored
Sep 10, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix indentation
R=r DELTA=166 (0 added, 0 deleted, 166 changed) OCL=34521 CL=34527
parent
61f27d3c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
146 additions
and
146 deletions
+146
-146
print.go
src/pkg/fmt/print.go
+146
-146
No files found.
src/pkg/fmt/print.go
View file @
8f2bf201
...
...
@@ -666,172 +666,172 @@ func (p *pp) doprintf(format string, v *reflect.StructValue) {
s
:=
""
;
switch
c
{
// bool
case
't'
:
if
v
,
ok
:=
getBool
(
field
);
ok
{
if
v
{
s
=
"true"
;
}
else
{
s
=
"false"
;
}
// bool
case
't'
:
if
v
,
ok
:=
getBool
(
field
);
ok
{
if
v
{
s
=
"true"
;
}
else
{
goto
badtype
;
s
=
"false"
;
}
}
else
{
goto
badtype
;
}
// int
case
'b'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_b64
(
uint64
(
v
))
.
Str
()
// always unsigned
}
else
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_fb32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_fb64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'c'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_c
(
int
(
v
))
.
Str
()
}
else
{
goto
badtype
}
case
'd'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
if
signed
{
s
=
p
.
fmt
.
Fmt_d64
(
v
)
.
Str
()
}
else
{
s
=
p
.
fmt
.
Fmt_ud64
(
uint64
(
v
))
.
Str
()
}
// int
case
'b'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_b64
(
uint64
(
v
))
.
Str
()
// always unsigned
}
else
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_fb32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_fb64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'c'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_c
(
int
(
v
))
.
Str
()
}
else
{
goto
badtype
}
case
'd'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
if
signed
{
s
=
p
.
fmt
.
Fmt_d64
(
v
)
.
Str
()
}
else
{
goto
badtype
s
=
p
.
fmt
.
Fmt_ud64
(
uint64
(
v
))
.
Str
()
}
case
'o'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
if
signed
{
s
=
p
.
fmt
.
Fmt_o64
(
v
)
.
Str
()
}
else
{
s
=
p
.
fmt
.
Fmt_uo64
(
uint64
(
v
))
.
Str
()
}
}
else
{
goto
badtype
}
case
'o'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
if
signed
{
s
=
p
.
fmt
.
Fmt_o64
(
v
)
.
Str
()
}
else
{
goto
badtype
s
=
p
.
fmt
.
Fmt_uo64
(
uint64
(
v
))
.
Str
()
}
case
'x'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
if
signed
{
s
=
p
.
fmt
.
Fmt_x64
(
v
)
.
Str
()
}
else
{
s
=
p
.
fmt
.
Fmt_ux64
(
uint64
(
v
))
.
Str
()
}
}
else
if
v
,
ok
:=
getString
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_sx
(
v
)
.
Str
();
}
else
{
goto
badtype
}
case
'x'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
if
signed
{
s
=
p
.
fmt
.
Fmt_x64
(
v
)
.
Str
()
}
else
{
goto
badtype
s
=
p
.
fmt
.
Fmt_ux64
(
uint64
(
v
))
.
Str
()
}
case
'X'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
if
signed
{
s
=
p
.
fmt
.
Fmt_X64
(
v
)
.
Str
()
}
else
{
s
=
p
.
fmt
.
Fmt_uX64
(
uint64
(
v
))
.
Str
()
}
}
else
if
v
,
ok
:=
getString
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_
sX
(
v
)
.
Str
();
}
else
if
v
,
ok
:=
getString
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_sx
(
v
)
.
Str
();
}
else
{
goto
badtype
}
case
'X'
:
if
v
,
signed
,
ok
:=
getInt
(
field
);
ok
{
if
signed
{
s
=
p
.
fmt
.
Fmt_
X64
(
v
)
.
Str
()
}
else
{
goto
badtype
s
=
p
.
fmt
.
Fmt_uX64
(
uint64
(
v
))
.
Str
()
}
}
else
if
v
,
ok
:=
getString
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_sX
(
v
)
.
Str
();
}
else
{
goto
badtype
}
// float
case
'e'
:
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_e32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_e64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'E'
:
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_E32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_E64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'f'
:
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_f32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_f64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'g'
:
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_g32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_g64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'G'
:
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_G32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_G64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
// float
case
'e'
:
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_e32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_e64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'E'
:
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_E32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_E64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'f'
:
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_f32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_f64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'g'
:
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_g32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_g64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'G'
:
if
v
,
ok
:=
getFloat32
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_G32
(
v
)
.
Str
()
}
else
if
v
,
ok
:=
getFloat64
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_G64
(
v
)
.
Str
()
}
else
{
goto
badtype
}
// string
case
's'
:
if
inter
!=
nil
{
// if object implements String, use the result.
if
stringer
,
ok
:=
inter
.
(
Stringer
);
ok
{
s
=
p
.
fmt
.
Fmt_s
(
stringer
.
String
())
.
Str
();
break
;
}
}
if
v
,
ok
:=
getString
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_s
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'q'
:
if
v
,
ok
:=
getString
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_q
(
v
)
.
Str
()
}
else
{
goto
badtype
// string
case
's'
:
if
inter
!=
nil
{
// if object implements String, use the result.
if
stringer
,
ok
:=
inter
.
(
Stringer
);
ok
{
s
=
p
.
fmt
.
Fmt_s
(
stringer
.
String
())
.
Str
();
break
;
}
}
if
v
,
ok
:=
getString
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_s
(
v
)
.
Str
()
}
else
{
goto
badtype
}
case
'q'
:
if
v
,
ok
:=
getString
(
field
);
ok
{
s
=
p
.
fmt
.
Fmt_q
(
v
)
.
Str
()
}
else
{
goto
badtype
}
// pointer
case
'p'
:
if
v
,
ok
:=
getPtr
(
field
);
ok
{
if
v
==
0
{
s
=
"<nil>"
}
else
{
s
=
"0x"
+
p
.
fmt
.
Fmt_uX64
(
uint64
(
v
))
.
Str
()
}
// pointer
case
'p'
:
if
v
,
ok
:=
getPtr
(
field
);
ok
{
if
v
==
0
{
s
=
"<nil>"
}
else
{
goto
badtype
s
=
"0x"
+
p
.
fmt
.
Fmt_uX64
(
uint64
(
v
))
.
Str
()
}
}
else
{
goto
badtype
}
// arbitrary value; do your best
case
'v'
:
plus
,
sharp
:=
p
.
fmt
.
plus
,
p
.
fmt
.
sharp
;
p
.
fmt
.
plus
=
false
;
p
.
fmt
.
sharp
=
false
;
p
.
printField
(
field
,
plus
,
sharp
,
0
);
// arbitrary value; do your best
case
'v'
:
plus
,
sharp
:=
p
.
fmt
.
plus
,
p
.
fmt
.
sharp
;
p
.
fmt
.
plus
=
false
;
p
.
fmt
.
sharp
=
false
;
p
.
printField
(
field
,
plus
,
sharp
,
0
);
// the value's type
case
'T'
:
s
=
field
.
Type
()
.
String
();
// the value's type
case
'T'
:
s
=
field
.
Type
()
.
String
();
default
:
badtype
:
s
=
"%"
+
string
(
c
)
+
"("
+
field
.
Type
()
.
String
()
+
"="
;
p
.
addstr
(
s
);
p
.
printField
(
field
,
false
,
false
,
0
);
s
=
")"
;
default
:
badtype
:
s
=
"%"
+
string
(
c
)
+
"("
+
field
.
Type
()
.
String
()
+
"="
;
p
.
addstr
(
s
);
p
.
printField
(
field
,
false
,
false
,
0
);
s
=
")"
;
}
p
.
addstr
(
s
);
}
...
...
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