aboutsummaryrefslogtreecommitdiff
path: root/src/text/template/parse/node.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2024-06-14 09:48:09 +1000
committerGopher Robot <gobot@golang.org>2024-06-21 18:12:29 +0000
commit6fea4094242fe4e7be8bd7ec0b55df9f6df3f025 (patch)
tree6f4f6a0af94523f28a452f1485c709fca04457aa /src/text/template/parse/node.go
parentd67839f58af518bfa32e27962059291362186e1c (diff)
downloadgo-6fea4094242fe4e7be8bd7ec0b55df9f6df3f025.tar.xz
text/template/parse: fix handling of assignment/declaration in PipeNode.String
The String method for Pipes assumed all variables were declared. Easy fix: check the IsAssign bit. Fixes #65382 Change-Id: I58f2760c1a8bb2821c3538645d893f58fd76ae73 Reviewed-on: https://go-review.googlesource.com/c/go/+/592695 Run-TryBot: Rob Pike <r@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Rob Pike <r@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/text/template/parse/node.go')
-rw-r--r--src/text/template/parse/node.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/text/template/parse/node.go b/src/text/template/parse/node.go
index 23ba9aec2b..a31309874d 100644
--- a/src/text/template/parse/node.go
+++ b/src/text/template/parse/node.go
@@ -217,7 +217,11 @@ func (p *PipeNode) writeTo(sb *strings.Builder) {
}
v.writeTo(sb)
}
- sb.WriteString(" := ")
+ if p.IsAssign {
+ sb.WriteString(" = ")
+ } else {
+ sb.WriteString(" := ")
+ }
}
for i, c := range p.Cmds {
if i > 0 {