diff options
Diffstat (limited to 'internal/texttemplate/exec.go')
| -rw-r--r-- | internal/texttemplate/exec.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/texttemplate/exec.go b/internal/texttemplate/exec.go new file mode 100644 index 00000000..f4906cb3 --- /dev/null +++ b/internal/texttemplate/exec.go @@ -0,0 +1,24 @@ +// 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() +} |
