forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.go
76 lines (63 loc) · 1.05 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package ravendb
import (
"fmt"
"strconv"
"strings"
)
var (
// if true, does verbose logging.
LogVerbose = false
)
func dbg(format string, args ...interface{}) {
if LogVerbose {
fmt.Printf(format, args...)
}
}
func must(err error) {
if err != nil {
panic(err)
}
}
func panicIf(cond bool, format string, args ...interface{}) {
if cond {
err := fmt.Errorf(format, args...)
must(err)
}
}
func i64toa(n int64) string {
return strconv.FormatInt(n, 10)
}
func min(i1, i2 int) int {
if i1 < i2 {
return i1
}
return i2
}
func firstNonNilString(s1, s2 *string) *string {
if s1 != nil {
return s1
}
return s2
}
func firstNonEmptyString(s1, s2 string) string {
if s1 != "" {
return s1
}
return s2
}
func firstNonZero(i1, i2 int) int {
if i1 != 0 {
return i1
}
return i2
}
func deepCopy(v interface{}) interface{} {
// TODO: implement me
return v
}
func builderWriteInt(b *strings.Builder, n int) {
b.WriteString(strconv.Itoa(n))
}
func builderWriteFloat64(b *strings.Builder, f float64) {
b.WriteString(fmt.Sprintf("%f", f))
}