From b3f624151c72f956ec31e275ec20e70fe4199250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Tikvi=C4=87?= Date: Thu, 14 Nov 2019 15:10:51 +0100 Subject: [PATCH] StringToValidInt64() --- int_util.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/int_util.go b/int_util.go index 7b5b733..39eea76 100644 --- a/int_util.go +++ b/int_util.go @@ -50,3 +50,11 @@ func BoolToInt64(b bool) int64 { func Int64ToBool(i int64) bool { return i != 0 } + +func StringToValidInt64(s string) (int64, bool) { + i, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return i, false + } + return i, true +} -- 1.8.1.2