aboutsummaryrefslogtreecommitdiff
path: root/src/text/template/exec.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/text/template/exec.go')
-rw-r--r--src/text/template/exec.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/text/template/exec.go b/src/text/template/exec.go
index 7e44497530..c42cbb2ad3 100644
--- a/src/text/template/exec.go
+++ b/src/text/template/exec.go
@@ -635,10 +635,13 @@ func (s *state) evalField(dot reflect.Value, fieldName string, node parse.Node,
case reflect.Struct:
tField, ok := receiver.Type().FieldByName(fieldName)
if ok {
- field := receiver.FieldByIndex(tField.Index)
+ field, err := receiver.FieldByIndexErr(tField.Index)
if !tField.IsExported() {
s.errorf("%s is an unexported field of struct type %s", fieldName, typ)
}
+ if err != nil {
+ s.errorf("%v", err)
+ }
// If it's a function, we must call it.
if hasArgs {
s.errorf("%s has arguments but cannot be invoked as function", fieldName)