"io"
"io/ioutil"
"path/filepath"
- "reflect"
"sync"
"text/template"
"text/template/parse"
// IsTrue reports whether the value is 'true', in the sense of not the zero of its type,
// and whether the value has a meaningful truth value. This is the definition of
// truth used by if and other such actions.
-func IsTrue(val reflect.Value) (truth, ok bool) {
+func IsTrue(val interface{}) (truth, ok bool) {
return template.IsTrue(val)
}
func (s *state) walkIfOrWith(typ parse.NodeType, dot reflect.Value, pipe *parse.PipeNode, list, elseList *parse.ListNode) {
defer s.pop(s.mark())
val := s.evalPipeline(dot, pipe)
- truth, ok := IsTrue(val)
+ truth, ok := isTrue(val)
if !ok {
s.errorf("if/with can't use %v", val)
}
// IsTrue reports whether the value is 'true', in the sense of not the zero of its type,
// and whether the value has a meaningful truth value. This is the definition of
// truth used by if and other such actions.
-func IsTrue(val reflect.Value) (truth, ok bool) {
+func IsTrue(val interface{}) (truth, ok bool) {
+ return isTrue(reflect.ValueOf(val))
+}
+
+func isTrue(val reflect.Value) (truth, ok bool) {
if !val.IsValid() {
// Something like var x interface{}, never set. It's a form of nil.
return false, true