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