Special-case an sprintf argument of []*operand type, similar to what
we do for other lists. As a result a list of operands is printed as
[a, b, c] rather than [a b c] (default formatting for slices).
(We could factor out this code into a generic function, but this is
a minimally intrusive change at this point.)
Change-Id: Iea4fc6ea375dd9618316b7317a77b57b4e35544d
Reviewed-on: https://go-review.googlesource.com/c/go/+/724500
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
panic("got operand instead of *operand")
case *operand:
arg = operandString(a, qf)
+ case []*operand:
+ var buf strings.Builder
+ buf.WriteByte('[')
+ for i, x := range a {
+ if i > 0 {
+ buf.WriteString(", ")
+ }
+ buf.WriteString(operandString(x, qf))
+ }
+ buf.WriteByte(']')
+ arg = buf.String()
case syntax.Pos:
arg = a.String()
case syntax.Expr:
panic("got operand instead of *operand")
case *operand:
arg = operandString(a, qf)
+ case []*operand:
+ var buf strings.Builder
+ buf.WriteByte('[')
+ for i, x := range a {
+ if i > 0 {
+ buf.WriteString(", ")
+ }
+ buf.WriteString(operandString(x, qf))
+ }
+ buf.WriteByte(']')
+ arg = buf.String()
case token.Pos:
if fset != nil {
arg = fset.Position(a).String()