github.com/zaolin/u-root@v0.0.0-20200428085104-64aaafd46c6d/cmds/core/elvish/eval/vals/bool.go (about) 1 package vals 2 3 // Booler wraps the Bool method. 4 type Booler interface { 5 // Bool computes the truth value of the receiver. 6 Bool() bool 7 } 8 9 // Bool converts a value to bool. It is implemented for the builtin bool type 10 // and types implementing the Booler interface. For all other values, it returns 11 // true. 12 func Bool(v interface{}) bool { 13 switch v := v.(type) { 14 case Booler: 15 return v.Bool() 16 case bool: 17 return v 18 } 19 return true 20 }