diff options
Diffstat (limited to 'src/pkg/html/template/content.go')
-rw-r--r-- | src/pkg/html/template/content.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pkg/html/template/content.go b/src/pkg/html/template/content.go index 9d1f74f6f..41b1116a6 100644 --- a/src/pkg/html/template/content.go +++ b/src/pkg/html/template/content.go @@ -74,6 +74,9 @@ const ( // indirect returns the value, after dereferencing as many times // as necessary to reach the base type (or nil). func indirect(a interface{}) interface{} { + if a == nil { + return nil + } if t := reflect.TypeOf(a); t.Kind() != reflect.Ptr { // Avoid creating a reflect.Value if it's not a pointer. return a @@ -94,6 +97,9 @@ var ( // as necessary to reach the base type (or nil) or an implementation of fmt.Stringer // or error, func indirectToStringerOrError(a interface{}) interface{} { + if a == nil { + return nil + } v := reflect.ValueOf(a) for !v.Type().Implements(fmtStringerType) && !v.Type().Implements(errorType) && v.Kind() == reflect.Ptr && !v.IsNil() { v = v.Elem() |