Commit b3f624151c72f956ec31e275ec20e70fe4199250
1 parent
ff845040c1
Exists in
master
StringToValidInt64()
Showing
1 changed file
with
8 additions
and
0 deletions
Show diff stats
int_util.go
... | ... | @@ -50,3 +50,11 @@ func BoolToInt64(b bool) int64 { |
50 | 50 | func Int64ToBool(i int64) bool { |
51 | 51 | return i != 0 |
52 | 52 | } |
53 | + | |
54 | +func StringToValidInt64(s string) (int64, bool) { | |
55 | + i, err := strconv.ParseInt(s, 10, 64) | |
56 | + if err != nil { | |
57 | + return i, false | |
58 | + } | |
59 | + return i, true | |
60 | +} | ... | ... |