3
0
corteza/server/pkg/id/conv.go
Tomaž Jerman 88804b460e Change filter slices to be []string vs []uint64
This is to allow front-end to properly handle ID values.
This change was done to keep consistent with what we were doing
before. Alternative version would be to have a sepparate struct
on the rest package.
2023-05-24 12:26:01 +02:00

32 lines
461 B
Go

package id
import "strconv"
func Strings(ii ...uint64) []string {
ss := make([]string, len(ii))
for i, v := range ii {
ss[i] = String(v)
}
return ss
}
func String(i uint64) string {
return strconv.FormatUint(i, 10)
}
func Uints(ss ...string) []uint64 {
uu := make([]uint64, len(ss))
for i, s := range ss {
uu[i] = Uint(s)
}
return uu
}
func Uint(s string) uint64 {
if s == "" {
return 0
}
i, _ := strconv.ParseUint(s, 10, 64)
return i
}