Add ParseUint64 function

This commit is contained in:
chrislusf 2015-05-25 23:51:12 -07:00
parent 36a31771f1
commit c89b4fd18b

View file

@ -5,7 +5,7 @@ import (
)
func ParseInt(text string, defaultValue int) int {
count, parseError := strconv.ParseUint(text, 10, 64)
count, parseError := strconv.ParseInt(text, 10, 64)
if parseError != nil {
if len(text) > 0 {
return 0
@ -14,3 +14,13 @@ func ParseInt(text string, defaultValue int) int {
}
return int(count)
}
func ParseUint64(text string, defaultValue uint64) uint64 {
count, parseError := strconv.ParseUint(text, 10, 64)
if parseError != nil {
if len(text) > 0 {
return 0
}
return defaultValue
}
return count
}