forked from snowflakedb/gosnowflake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
49 lines (42 loc) · 907 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2017-2019 Snowflake Computing Inc. All right reserved.
package gosnowflake
import (
"database/sql/driver"
"time"
)
// integer min
func intMin(a, b int) int {
if a < b {
return a
}
return b
}
// integer max
func intMax(a, b int) int {
if a > b {
return a
}
return b
}
// time.Duration max
func durationMax(d1, d2 time.Duration) time.Duration {
if d1-d2 > 0 {
return d1
}
return d2
}
// time.Duration min
func durationMin(d1, d2 time.Duration) time.Duration {
if d1-d2 < 0 {
return d1
}
return d2
}
// toNamedValues converts a slice of driver.Value to a slice of driver.NamedValue for Go 1.8 SQL package
func toNamedValues(values []driver.Value) []driver.NamedValue {
namedValues := make([]driver.NamedValue, len(values))
for idx, value := range values {
namedValues[idx] = driver.NamedValue{Name: "", Ordinal: idx + 1, Value: value}
}
return namedValues
}