Bh/clone2 (#83)

New clone implementation works on the table files directly.
This commit is contained in:
Brian Hendriks
2019-09-17 17:14:06 -07:00
committed by GitHub
parent 1bcc547c2e
commit 1435a8f509
19 changed files with 1085 additions and 188 deletions
+22
View File
@@ -14,6 +14,8 @@
package strhelp
import "strconv"
// NthToken returns the Nth token in s, delimited by delim. There is always at least one token: the zeroth token is the
// input string if delim doesn't occur in s. The second return value will be false if there is no Nth token.
func NthToken(s string, delim rune, n int) (string, bool) {
@@ -41,3 +43,23 @@ func NthToken(s string, delim rune, n int) (string, bool) {
return "", false
}
func CommaIfy(n int64) string {
str := strconv.FormatInt(n, 10)
if len(str) < 4 {
return str
}
result := ""
for i := len(str); i >= 0; i -= 3 {
if i-4 >= 0 {
result = "," + str[i-3:i] + result
} else {
result = str[0:i] + result
}
}
return result
}