// Taken and adapted from the stdlib text/template/funcs.go. // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package texttemplate import ( "reflect" ) // indirectInterface returns the concrete value in an interface value, // or else the zero reflect.Value. // That is, if v represents the interface value x, the result is the same as reflect.ValueOf(x): // the fact that x was an interface value is forgotten. func indirectInterface(v reflect.Value) reflect.Value { if v.Kind() != reflect.Interface { return v } if v.IsNil() { return reflect.Value{} } return v.Elem() }