aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/pprof
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/runtime/pprof
parent083ef5462494e81ee23316245c5d65085a3f62d9 (diff)
downloadgo-2580d0e08d5e9f979b943758d3c49877fb2324cb.tar.xz
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/runtime/pprof')
-rw-r--r--src/runtime/pprof/mprof_test.go2
-rw-r--r--src/runtime/pprof/pprof.go8
-rw-r--r--src/runtime/pprof/pprof_test.go4
-rw-r--r--src/runtime/pprof/proto_test.go2
4 files changed, 8 insertions, 8 deletions
diff --git a/src/runtime/pprof/mprof_test.go b/src/runtime/pprof/mprof_test.go
index ab8341d32f..665487a7c4 100644
--- a/src/runtime/pprof/mprof_test.go
+++ b/src/runtime/pprof/mprof_test.go
@@ -17,7 +17,7 @@ import (
"unsafe"
)
-var memSink interface{}
+var memSink any
func allocateTransient1M() {
for i := 0; i < 1024; i++ {
diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go
index 000abf935c..d75efce7a8 100644
--- a/src/runtime/pprof/pprof.go
+++ b/src/runtime/pprof/pprof.go
@@ -134,7 +134,7 @@ import (
type Profile struct {
name string
mu sync.Mutex
- m map[interface{}][]uintptr
+ m map[any][]uintptr
count func() int
write func(io.Writer, int) error
}
@@ -217,7 +217,7 @@ func NewProfile(name string) *Profile {
}
p := &Profile{
name: name,
- m: map[interface{}][]uintptr{},
+ m: map[any][]uintptr{},
}
profiles.m[name] = p
return p
@@ -277,7 +277,7 @@ func (p *Profile) Count() int {
// Passing skip=0 begins the stack trace at the call to Add inside rpc.NewClient.
// Passing skip=1 begins the stack trace at the call to NewClient inside mypkg.Run.
//
-func (p *Profile) Add(value interface{}, skip int) {
+func (p *Profile) Add(value any, skip int) {
if p.name == "" {
panic("pprof: use of uninitialized Profile")
}
@@ -303,7 +303,7 @@ func (p *Profile) Add(value interface{}, skip int) {
// Remove removes the execution stack associated with value from the profile.
// It is a no-op if the value is not in the profile.
-func (p *Profile) Remove(value interface{}) {
+func (p *Profile) Remove(value any) {
p.mu.Lock()
defer p.mu.Unlock()
delete(p.m, value)
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index b3a8927dc7..d32046379a 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -235,14 +235,14 @@ func TestCPUProfileMultithreadMagnitude(t *testing.T) {
// containsInlinedCall reports whether the function body for the function f is
// known to contain an inlined function call within the first maxBytes bytes.
-func containsInlinedCall(f interface{}, maxBytes int) bool {
+func containsInlinedCall(f any, maxBytes int) bool {
_, found := findInlinedCall(f, maxBytes)
return found
}
// findInlinedCall returns the PC of an inlined function call within
// the function body for the function f if any.
-func findInlinedCall(f interface{}, maxBytes int) (pc uint64, found bool) {
+func findInlinedCall(f any, maxBytes int) (pc uint64, found bool) {
fFunc := runtime.FuncForPC(uintptr(abi.FuncPCABIInternal(f)))
if fFunc == nil || fFunc.Entry() == 0 {
panic("failed to locate function entry")
diff --git a/src/runtime/pprof/proto_test.go b/src/runtime/pprof/proto_test.go
index ea0ed9aefd..84a051a536 100644
--- a/src/runtime/pprof/proto_test.go
+++ b/src/runtime/pprof/proto_test.go
@@ -40,7 +40,7 @@ func translateCPUProfile(data []uint64, count int) (*profile.Profile, error) {
// fmtJSON returns a pretty-printed JSON form for x.
// It works reasonbly well for printing protocol-buffer
// data structures like profile.Profile.
-func fmtJSON(x interface{}) string {
+func fmtJSON(x any) string {
js, _ := json.MarshalIndent(x, "", "\t")
return string(js)
}