diff --git a/ch3-asm/ch3-08-goroutine-id.md b/ch3-asm/ch3-08-goroutine-id.md index 2be476e..5931c37 100644 --- a/ch3-asm/ch3-08-goroutine-id.md +++ b/ch3-asm/ch3-08-goroutine-id.md @@ -62,11 +62,11 @@ main.main() func GetGoid() int64 { var ( buf [64]byte - n = runtime.Stack(buf[:], false) - stk = strings.TrimPrefix(string(buf[:n]) + n = runtime.Stack(buf[:], false) + 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))