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
1042d7d5
Commit
1042d7d5
authored
Mar 05, 2012
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expvar: add missing locking in String methods
R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/5726062
parent
c073a160
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
expvar.go
src/pkg/expvar/expvar.go
+15
-7
No files found.
src/pkg/expvar/expvar.go
View file @
1042d7d5
...
...
@@ -44,7 +44,11 @@ type Int struct {
mu
sync
.
Mutex
}
func
(
v
*
Int
)
String
()
string
{
return
strconv
.
FormatInt
(
v
.
i
,
10
)
}
func
(
v
*
Int
)
String
()
string
{
v
.
mu
.
Lock
()
defer
v
.
mu
.
Unlock
()
return
strconv
.
FormatInt
(
v
.
i
,
10
)
}
func
(
v
*
Int
)
Add
(
delta
int64
)
{
v
.
mu
.
Lock
()
...
...
@@ -64,7 +68,11 @@ type Float struct {
mu
sync
.
Mutex
}
func
(
v
*
Float
)
String
()
string
{
return
strconv
.
FormatFloat
(
v
.
f
,
'g'
,
-
1
,
64
)
}
func
(
v
*
Float
)
String
()
string
{
v
.
mu
.
Lock
()
defer
v
.
mu
.
Unlock
()
return
strconv
.
FormatFloat
(
v
.
f
,
'g'
,
-
1
,
64
)
}
// Add adds delta to v.
func
(
v
*
Float
)
Add
(
delta
float64
)
{
...
...
@@ -95,17 +103,17 @@ type KeyValue struct {
func
(
v
*
Map
)
String
()
string
{
v
.
mu
.
RLock
()
defer
v
.
mu
.
RUnlock
()
b
:=
new
(
bytes
.
Buffer
)
fmt
.
Fprintf
(
b
,
"{"
)
var
b
bytes
.
Buffer
fmt
.
Fprintf
(
&
b
,
"{"
)
first
:=
true
for
key
,
val
:=
range
v
.
m
{
if
!
first
{
fmt
.
Fprintf
(
b
,
", "
)
fmt
.
Fprintf
(
&
b
,
", "
)
}
fmt
.
Fprintf
(
b
,
"
\"
%s
\"
: %v"
,
key
,
val
)
fmt
.
Fprintf
(
&
b
,
"
\"
%s
\"
: %v"
,
key
,
val
)
first
=
false
}
fmt
.
Fprintf
(
b
,
"}"
)
fmt
.
Fprintf
(
&
b
,
"}"
)
return
b
.
String
()
}
...
...
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