Make some API changes (currently broken)

This commit is contained in:
Neil Alexander 2019-08-05 00:30:12 +01:00
parent a2966291b9
commit 37533f157d
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 84 additions and 81 deletions

View file

@ -2,9 +2,13 @@ package util
// These are misc. utility functions that didn't really fit anywhere else
import "runtime"
import "sync"
import "time"
import (
"runtime"
"strconv"
"strings"
"sync"
"time"
)
// A wrapper around runtime.Gosched() so it doesn't need to be imported elsewhere.
func Yield() {
@ -91,3 +95,16 @@ func Difference(a, b []string) []string {
}
return ab
}
// DecodeCoordString decodes a string representing coordinates in [1 2 3] format
// and returns a []byte.
func DecodeCoordString(in string) (out []uint64) {
s := strings.Trim(in, "[]")
t := strings.Split(s, " ")
for _, a := range t {
if u, err := strconv.ParseUint(a, 0, 64); err == nil {
out = append(out, u)
}
}
return out
}