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
8bfa9175
Commit
8bfa9175
authored
Dec 20, 2010
by
David Symonds
Committed by
Andrew Gerrand
Dec 20, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expvar: quote StringFunc output, same as String output.
R=adg CC=golang-dev
https://golang.org/cl/3797041
parent
2662b99f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
expvar.go
src/pkg/expvar/expvar.go
+1
-1
expvar_test.go
src/pkg/expvar/expvar_test.go
+15
-2
No files found.
src/pkg/expvar/expvar.go
View file @
8bfa9175
...
...
@@ -152,7 +152,7 @@ func (v IntFunc) String() string { return strconv.Itoa64(v()) }
// The function will be called each time the Var is evaluated.
type
StringFunc
func
()
string
func
(
f
StringFunc
)
String
()
string
{
return
f
(
)
}
func
(
f
StringFunc
)
String
()
string
{
return
strconv
.
Quote
(
f
()
)
}
// All published variables.
...
...
src/pkg/expvar/expvar_test.go
View file @
8bfa9175
...
...
@@ -86,8 +86,8 @@ func TestMapCounter(t *testing.T) {
}
func
TestIntFunc
(
t
*
testing
.
T
)
{
x
:=
int
(
4
)
ix
:=
IntFunc
(
func
()
int64
{
return
int64
(
x
)
})
x
:=
int
64
(
4
)
ix
:=
IntFunc
(
func
()
int64
{
return
x
})
if
s
:=
ix
.
String
();
s
!=
"4"
{
t
.
Errorf
(
"ix.String() = %v, want 4"
,
s
)
}
...
...
@@ -97,3 +97,16 @@ func TestIntFunc(t *testing.T) {
t
.
Errorf
(
"ix.String() = %v, want 5"
,
s
)
}
}
func
TestStringFunc
(
t
*
testing
.
T
)
{
x
:=
"hello"
sx
:=
StringFunc
(
func
()
string
{
return
x
})
if
s
,
exp
:=
sx
.
String
(),
`"hello"`
;
s
!=
exp
{
t
.
Errorf
(
`sx.String() = %q, want %q`
,
s
,
exp
)
}
x
=
"goodbye"
if
s
,
exp
:=
sx
.
String
(),
`"goodbye"`
;
s
!=
exp
{
t
.
Errorf
(
`sx.String() = %q, want %q`
,
s
,
exp
)
}
}
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