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