mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 04:22:22 +00:00
Merge pull request #410 from kumakichi/fix_code_snippet
fix code snippet
This commit is contained in:
commit
46bbb0e350
@ -63,10 +63,10 @@ func GetGoid() int64 {
|
||||
var (
|
||||
buf [64]byte
|
||||
n = runtime.Stack(buf[:], false)
|
||||
stk = strings.TrimPrefix(string(buf[:n])
|
||||
stk = strings.TrimPrefix(string(buf[:n]), "goroutine ")
|
||||
)
|
||||
|
||||
idField := strings.Fields(stk, "goroutine "))[0]
|
||||
idField := strings.Fields(stk)[0]
|
||||
id, err := strconv.Atoi(idField)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("can not get goroutine id: %v", err))
|
||||
|
Loading…
x
Reference in New Issue
Block a user