diff --git a/service/dap/server.go b/service/dap/server.go index 19c1856b4a..08a3b2e7d1 100644 --- a/service/dap/server.go +++ b/service/dap/server.go @@ -1800,7 +1800,7 @@ func (s *Session) onThreadsRequest(request *dap.ThreadsRequest) { if g.Thread != nil && g.Thread.ThreadID() != 0 { thread = fmt.Sprintf(" (Thread %d)", g.Thread.ThreadID()) } - labels := "" + var labels strings.Builder if len(g.Labels()) > 0 { var keys []string for k := range g.Labels() { @@ -1808,13 +1808,13 @@ func (s *Session) onThreadsRequest(request *dap.ThreadsRequest) { } sort.Strings(keys) for _, k := range keys { - labels += fmt.Sprintf(" %s=%s", k, g.Labels()[k]) + fmt.Fprintf(&labels, " %s=%s", k, g.Labels()[k]) } } // File name and line number are communicated via `stackTrace` // so no need to include them here. loc := g.UserCurrent() - threads[i].Name = fmt.Sprintf("%s[Go %d%s] %s%s", selected, g.ID, labels, fnName(&loc), thread) + threads[i].Name = fmt.Sprintf("%s[Go %d%s] %s%s", selected, g.ID, labels.String(), fnName(&loc), thread) threads[i].Id = int(g.ID) } }