Example #1
0
func Bool(m map[string]interface{}, key string) (bool, bool) {
	v, ok := m[key]
	if !ok {
		return false, false
	}
	return vu.Bool(v)
}
Example #2
0
File: row.go Project: najeira/sql
// Bool returns the boolean value for the column in the row.
// It returns false if not found or it is not boolean.
func (m Row) Bool(column string, args ...interface{}) bool {
	if v, ok := m[column]; ok {
		if ns, ok := v.(NullBool); ok && ns.Valid {
			return ns.Bool
		} else if ns, ok := v.(*NullBool); ok && ns.Valid {
			return ns.Bool
		} else if s, ok := varutil.Bool(v); ok {
			return s
		}
	}
	if len(args) > 0 {
		return varutil.AsBool(args[0])
	}
	return false
}