expvar: document that Get returns nil for non-existent vars
Also added a test to ensure the behavior.
Fixes #14150
Change-Id: Ib3ee9fdae59826fa594ce1be3c49b51d740b56eb
Reviewed-on: https://go-review.googlesource.com/19915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/src/expvar/expvar_test.go b/src/expvar/expvar_test.go
index 8bc633e..385fea8 100644
--- a/src/expvar/expvar_test.go
+++ b/src/expvar/expvar_test.go
@@ -26,6 +26,14 @@
varKeys = nil
}
+func TestNil(t *testing.T) {
+ RemoveAll()
+ val := Get("missing")
+ if val != nil {
+ t.Errorf("got %v, want nil", val)
+ }
+}
+
func TestInt(t *testing.T) {
RemoveAll()
reqs := NewInt("requests")