1
0
mirror of https://github.com/golang/go synced 2024-09-28 17:24:28 -06:00

Simplify unwrapping reflect.Interface value in text/template

This commit is contained in:
Joe Taber 2024-03-18 00:23:18 -05:00 committed by GitHub
parent 0a6f05e30f
commit bdfc6973ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -479,7 +479,7 @@ func (s *state) evalPipeline(dot reflect.Value, pipe *parse.PipeNode) (value ref
value = s.evalCommand(dot, cmd, value) // previous value is this one's final arg.
// If the object has type interface{}, dig down one level to the thing inside.
if value.Kind() == reflect.Interface && value.Type().NumMethod() == 0 {
value = reflect.ValueOf(value.Interface()) // lovely!
value = value.Elem()
}
}
for _, variable := range pipe.Decl {