• Russ Cox's avatar
    text/template: add support for reflect.Value args, results in funcs · 5378dd77
    Russ Cox authored
    Add support for passing reflect.Values to and returning reflect.Values from
    any registered functions in the FuncMap, much as if they were
    interface{} values. Keeping the reflect.Value instead of round-tripping
    to interface{} preserves addressability of the value, which is important
    for method lookup.
    
    Change index and a few other built-in functions to use reflect.Values,
    making a loop using explicit indexing now match the semantics that
    range has always had.
    
    Fixes #14916.
    
    Change-Id: Iae1a2fd9bb426886a7fcd9204f30a2d6ad4646ad
    Reviewed-on: https://go-review.googlesource.com/31462Reviewed-by: 's avatarRob Pike <r@golang.org>
    5378dd77
funcs.go 16 KB