|
|
|
Created:
16 years, 1 month ago by sven Modified:
2 years, 2 months ago Reviewers:
CC:
rsc Visibility:
Public. |
Derefer interfaces when looping in templates
Patch Set 1 : code review 161067: Derefer interfaces when looping in templates #
Total messages: 4
|
sven
Hello rsc (cc: sven), I'd like you to review the following change.
|
16 years, 1 month ago (2009年11月28日 19:18:26 UTC) #1 | ||||||||||||||
Hello rsc (cc: sven), I'd like you to review the following change.
Thanks. Could you please fill out the CLA as described at http://golang.org/doc/contribute.html#copyright and let me know once you have. There's no need to create a separate AUTHORS/CONTRIBUTORS CL - we'll take care of that - just let me know once you've filled out the form. For this change, it's maybe overkill, but people who send small changes typically end up being people who send more substantial changes later, and this will get that out of the way. Thanks. On Sat, Nov 28, 2009 at 11:18, <sven@tras.se> wrote: > Reviewers: rsc, > > Message: > Hello rsc (cc: sven), > > I'd like you to review the following change. > > > Description: > Derefer interfaces when looping in templates > > Please review this at http://codereview.appspot.com/161067 > > Affected files: > M src/pkg/template/template.go > > > Index: src/pkg/template/template.go > =================================================================== > --- a/src/pkg/template/template.go > +++ b/src/pkg/template/template.go > @@ -774,6 +774,10 @@ > } > first := true; > > + if iface, ok := field.(*reflect.InterfaceValue); ok { > + field = iface.Elem() > + } > + > if array, ok := field.(reflect.ArrayOrSliceValue); ok { > for j := 0; j < array.Len(); j++ { > newst := st.clone(array.Elem(j)); > > >
This looks great. Could you please add a test in template_test.go to make sure that the code works and, more importantly, to make sure that we don't break it in the future? After changing template_test.go: cd $GOROOT/src/pkg/template hg file 161067 template_test.go hg mail 161067 Thanks. Russ