summaryrefslogtreecommitdiff
path: root/src/expvar
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2021-12-01 12:15:45 -0500
committerRuss Cox <rsc@golang.org>2021-12-13 18:45:54 +0000
commit2580d0e08d5e9f979b943758d3c49877fb2324cb (patch)
tree3aafccfd81087734156a1778ce2321adf345f271 /src/expvar
parent083ef5462494e81ee23316245c5d65085a3f62d9 (diff)
downloadgo-git-2580d0e08d5e9f979b943758d3c49877fb2324cb.tar.gz
all: gofmt -w -r 'interface{} -> any' src
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/expvar')
-rw-r--r--src/expvar/expvar.go10
-rw-r--r--src/expvar/expvar_test.go8
2 files changed, 9 insertions, 9 deletions
diff --git a/src/expvar/expvar.go b/src/expvar/expvar.go
index 13b5c99b6e..8bbf41b151 100644
--- a/src/expvar/expvar.go
+++ b/src/expvar/expvar.go
@@ -130,7 +130,7 @@ func (v *Map) Init() *Map {
v.keysMu.Lock()
defer v.keysMu.Unlock()
v.keys = v.keys[:0]
- v.m.Range(func(k, _ interface{}) bool {
+ v.m.Range(func(k, _ any) bool {
v.m.Delete(k)
return true
})
@@ -252,9 +252,9 @@ func (v *String) Set(value string) {
// Func implements Var by calling the function
// and formatting the returned value using JSON.
-type Func func() interface{}
+type Func func() any
-func (f Func) Value() interface{} {
+func (f Func) Value() any {
return f()
}
@@ -350,11 +350,11 @@ func Handler() http.Handler {
return http.HandlerFunc(expvarHandler)
}
-func cmdline() interface{} {
+func cmdline() any {
return os.Args
}
-func memstats() interface{} {
+func memstats() any {
stats := new(runtime.MemStats)
runtime.ReadMemStats(stats)
return *stats
diff --git a/src/expvar/expvar_test.go b/src/expvar/expvar_test.go
index 69b0a76058..ba95a36066 100644
--- a/src/expvar/expvar_test.go
+++ b/src/expvar/expvar_test.go
@@ -242,12 +242,12 @@ func TestMapCounter(t *testing.T) {
// colors.String() should be '{"red":3, "blue":4}',
// though the order of red and blue could vary.
s := colors.String()
- var j interface{}
+ var j any
err := json.Unmarshal([]byte(s), &j)
if err != nil {
t.Errorf("colors.String() isn't valid JSON: %v", err)
}
- m, ok := j.(map[string]interface{})
+ m, ok := j.(map[string]any)
if !ok {
t.Error("colors.String() didn't produce a map.")
}
@@ -427,8 +427,8 @@ func BenchmarkMapAddDifferentSteadyState(b *testing.B) {
func TestFunc(t *testing.T) {
RemoveAll()
- var x interface{} = []string{"a", "b"}
- f := Func(func() interface{} { return x })
+ var x any = []string{"a", "b"}
+ f := Func(func() any { return x })
if s, exp := f.String(), `["a","b"]`; s != exp {
t.Errorf(`f.String() = %q, want %q`, s, exp)
}