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
3b9c9d21
Commit
3b9c9d21
authored
Oct 11, 2010
by
Sam Thorogood
Committed by
Russ Cox
Oct 11, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expvar: add (*Int).Set
R=golang-dev, adg, rsc CC=golang-dev
https://golang.org/cl/2336044
parent
1abd293d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
expvar.go
src/pkg/expvar/expvar.go
+8
-0
expvar_test.go
src/pkg/expvar/expvar_test.go
+5
-0
No files found.
src/pkg/expvar/expvar.go
View file @
3b9c9d21
...
...
@@ -6,6 +6,8 @@
// such as operation counters in servers. It exposes these variables via
// HTTP at /debug/vars in JSON format.
//
// Operations to set or modify these public variables are atomic.
//
// In addition to adding the HTTP handler, this package registers the
// following variables:
//
...
...
@@ -50,6 +52,12 @@ func (v *Int) Add(delta int64) {
v
.
i
+=
delta
}
func
(
v
*
Int
)
Set
(
value
int64
)
{
v
.
mu
.
Lock
()
defer
v
.
mu
.
Unlock
()
v
.
i
=
value
}
// Map is a string-to-Var map variable, and satisfies the Var interface.
type
Map
struct
{
m
map
[
string
]
Var
...
...
src/pkg/expvar/expvar_test.go
View file @
3b9c9d21
...
...
@@ -27,6 +27,11 @@ func TestInt(t *testing.T) {
if
s
:=
reqs
.
String
();
s
!=
"4"
{
t
.
Errorf
(
"reqs.String() = %q, want
\"
4
\"
"
,
s
)
}
reqs
.
Set
(
-
2
)
if
reqs
.
i
!=
-
2
{
t
.
Errorf
(
"reqs.i = %v, want -2"
,
reqs
.
i
)
}
}
func
TestString
(
t
*
testing
.
T
)
{
...
...
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