]> Cypherpunks repositories - gostls13.git/commit
fmt: allow any type in a format's width argument
authorRob Pike <r@golang.org>
Thu, 10 Sep 2015 20:41:03 +0000 (13:41 -0700)
committerRob Pike <r@golang.org>
Thu, 10 Sep 2015 20:53:22 +0000 (20:53 +0000)
commita00cec90cadb023637622905c3bbb867de494cf3
tree7566115f61dc53c6cc3654a18e549cc52a9eba74
parent8b96be15f6632b33c7341840002bc5b0744b2977
fmt: allow any type in a format's width argument

The construction
fmt.Printf("%*d", n, 4)
reads the argument n as a width specifier to use when printing 4.
Until now, only strict int type was accepted here and it couldn't
be fixed because the fix, using reflection, broke escape analysis
and added an extra allocation in every Printf call, even those that
do not use this feature.

The compiler has been fixed, although I am not sure when exactly,
so let's fix Printf and then write

Fixes #10732.

Change-Id: I79cf0c4fadd876265aa39d3cb62867247b36ab65
Reviewed-on: https://go-review.googlesource.com/14491
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/fmt/fmt_test.go
src/fmt/print.go