diff options
| author | cuiweixie <cuiweixie@gmail.com> | 2022-09-27 23:06:11 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-09-27 17:14:59 +0000 |
| commit | 6c3567873c4c58fe5b9e9abe77fed826a8e2ac97 (patch) | |
| tree | fd34b3788c70a5c656122c7cdc8daa303ee6fc6c /src/runtime/testdata | |
| parent | b52783c1e9673793da85dc7a9fb433d033da2e10 (diff) | |
| download | go-6c3567873c4c58fe5b9e9abe77fed826a8e2ac97.tar.xz | |
runtime: using bytes.CutPrefix
Change-Id: I3f2dae17496b5b4efbdc022802f941a616abd87a
Reviewed-on: https://go-review.googlesource.com/c/go/+/435276
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/runtime/testdata')
| -rw-r--r-- | src/runtime/testdata/testprog/traceback_ancestors.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/runtime/testdata/testprog/traceback_ancestors.go b/src/runtime/testdata/testprog/traceback_ancestors.go index 1d0d00bab7..8fc1aa7dbb 100644 --- a/src/runtime/testdata/testprog/traceback_ancestors.go +++ b/src/runtime/testdata/testprog/traceback_ancestors.go @@ -87,9 +87,10 @@ func goroutineID() string { buf := make([]byte, 128) runtime.Stack(buf, false) prefix := []byte("goroutine ") - if !bytes.HasPrefix(buf, prefix) { + var found bool + if buf, found = bytes.CutPrefix(buf, prefix); !found { panic(fmt.Sprintf("expected %q at beginning of traceback:\n%s", prefix, buf)) } - id, _, _ := bytes.Cut(bytes.TrimPrefix(buf, prefix), []byte(" ")) + id, _, _ := bytes.Cut(buf, []byte(" ")) return string(id) } |
