text/template: reintroduce implicit indirect of interface values in builtin funcs
CL 31462 made it possible to operate directly on reflect.Values instead of always forcing a round trip to interface{} and back. The round trip was losing addressability, which hurt users. The round trip was also losing "interface-ness", which helped users. That is, using reflect.ValueOf(v.Interface()) instead of v was doing an implicit indirect any time v was itself an interface{} value: the result was the reflect.Value for the underlying concrete value contained in the interface, not the interface itself. CL 31462 eliminated some "unnecessary" reflect.Value round trips in order to preserve addressability, but in doing so it lost this implicit indirection. This CL adds the indirection back. It may help to compare the changes in this CL against funcs.go from CL 31462: https://go-review.googlesource.com/#/c/31462/4/src/text/template/funcs.go Everywhere CL 31462 changed 'v := reflect.ValueOf(x)' to 'v := x', this CL changes 'v := x' to 'v := indirectInterface(x)'. Fixes #17714. Change-Id: I67cec4eb41fed1d56e1c19f12b0abbd0e59d35a2 Reviewed-on: https://go-review.googlesource.com/33139 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Showing
Please
register
or
sign in
to comment