-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
Please answer these questions before submitting your issue. Thanks!
- What version of Go are you using (
go version)?
1.6.1 - What operating system and processor architecture are you using (
go env)?
linux amd64 - What did you do?
http://play.golang.org/p/Fk7G5f3z1q
The second template takes nil as its data, and accesses its .X field. - What did you expect to see?
I would expect the second template to return an error, just like the first:
template: :1:2: executing "" at <.X>: can't evaluate field X in type int - What did you see instead?
The second template writes out "" and returns no error.
This seems to correspond to the missingkey=default behaviour, which is documented to happen for maps. I don't think the empty interface should count as a map though, so I would have expected an error instead.
I can volunteer to provide a fix if the current behaviour is recognized to be a bug.