mirror of https://github.com/golang/go.git
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>
This commit is contained in:
parent
b52783c1e9
commit
6c3567873c
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue