From a616066dbf4b49e1cc9b8a472b0ac7f1b92c9d3c Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Tue, 20 Feb 2024 14:54:31 +0800 Subject: [PATCH] runtime/debug: stack test fail when GOROOT='/usr/local/go/' Fixes: #65506 Signed-off-by: guoguangwu --- src/runtime/debug/stack_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/runtime/debug/stack_test.go b/src/runtime/debug/stack_test.go index 289749ccb4..a704154b12 100644 --- a/src/runtime/debug/stack_test.go +++ b/src/runtime/debug/stack_test.go @@ -105,7 +105,12 @@ func TestStack(t *testing.T) { } filePrefix := "" if fileGoroot != "" { - filePrefix = filepath.ToSlash(fileGoroot) + "/src/" + fileGoroot = filepath.ToSlash(filepath.Clean(fileGoroot)) + if fileGoroot == "/" { + filePrefix = "/src/" + } else { + filePrefix = fileGoroot + "/src/" + } } n := 0