From e41adb305d31d2b81b0994d477b1526dff373996 Mon Sep 17 00:00:00 2001 From: san Date: Tue, 15 Jan 2019 23:16:05 +0800 Subject: [PATCH] fix code snippet --- ch3-asm/ch3-08-goroutine-id.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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))