forked from xyproto/simplemaria
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.go
More file actions
33 lines (27 loc) · 660 Bytes
/
Copy pathhelpers.go
File metadata and controls
33 lines (27 loc) · 660 Bytes
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
package simplesqlite
import (
"strings"
)
var Verbose = false
/* --- Helper functions --- */
// Split a string into two parts, given a delimiter.
// Returns the two parts and true if it works out.
func twoFields(s, delim string) (string, string, bool) {
if strings.Count(s, delim) != 1 {
return s, "", false
}
fields := strings.Split(s, delim)
return fields[0], fields[1], true
}
func leftOf(s, delim string) string {
if left, _, ok := twoFields(s, delim); ok {
return strings.TrimSpace(left)
}
return ""
}
func rightOf(s, delim string) string {
if _, right, ok := twoFields(s, delim); ok {
return strings.TrimSpace(right)
}
return ""
}