From a7fcdf37955a81a667347870ae8f3e8065e17c03 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Sun, 1 Jul 2018 01:46:24 +0200 Subject: [PATCH] import misc/util go files --- crm/misc.go | 10 ++++++++++ crm/util.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 crm/misc.go create mode 100644 crm/util.go diff --git a/crm/misc.go b/crm/misc.go new file mode 100644 index 000000000..2cf0fdf78 --- /dev/null +++ b/crm/misc.go @@ -0,0 +1,10 @@ +package crm + +import ( + "net/http" +) + +// RequestFiller is an interface for typed request parameters +type RequestFiller interface { + Fill(r *http.Request) error +} diff --git a/crm/util.go b/crm/util.go new file mode 100644 index 000000000..b08fdf726 --- /dev/null +++ b/crm/util.go @@ -0,0 +1,33 @@ +package crm + +import ( + "strconv" +) + +// parseInt64 parses an string to int64 +func parseInt64(s string) int64 { + if s == "" { + return 0 + } + i, _ := strconv.ParseInt(s, 10, 64) + return i +} + +// parseUInt64 parses an string to uint64 +func parseUInt64(s string) uint64 { + if s == "" { + return 0 + } + i, _ := strconv.ParseUint(s, 10, 64) + return i +} + +// is checks if string s is contained in matches +func is(s string, matches ...string) bool { + for _, v := range matches { + if s == v { + return true + } + } + return false +}