From 0c747b7aa757da0a0a0ac7b2b5834dca84c7c019 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 26 Nov 2025 17:53:04 -0500 Subject: [PATCH] go/build/constraint: use strings.Builder instead of for { str+=str } (This works around a bug in the stringsbuilder modernizer.) For #76476 Change-Id: I1cb8715fd79c0363cb9c159686eaeb3482c93228 Reviewed-on: https://go-review.googlesource.com/c/go/+/724721 Reviewed-by: Dmitri Shuralyov TryBot-Bypass: Alan Donovan Reviewed-by: Dmitri Shuralyov --- src/go/build/constraint/expr.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/go/build/constraint/expr.go b/src/go/build/constraint/expr.go index 1f39bb2011..943c8f3444 100644 --- a/src/go/build/constraint/expr.go +++ b/src/go/build/constraint/expr.go @@ -515,18 +515,18 @@ func PlusBuildLines(x Expr) ([]string, error) { // Prepare the +build lines. var lines []string for _, or := range split { - line := "// +build" + var line strings.Builder + line.WriteString("// +build") for _, and := range or { - clause := "" + line.WriteString(" ") for i, lit := range and { if i > 0 { - clause += "," + line.WriteString(",") } - clause += lit.String() + line.WriteString(lit.String()) } - line += " " + clause } - lines = append(lines, line) + lines = append(lines, line.String()) } return lines, nil -- 2.52.0