diff options
| author | chrislusf <chris.lu@gmail.com> | 2015-05-25 23:51:12 -0700 |
|---|---|---|
| committer | chrislusf <chris.lu@gmail.com> | 2015-05-25 23:51:12 -0700 |
| commit | c89b4fd18b80f04bdf229fdec570b5672223201f (patch) | |
| tree | 3445b373da9d1a666fb8dd3c9b5d8d3da2c8f61a /go/util/parse.go | |
| parent | 36a31771f1131f31b6783a8125e033b81a24e1a2 (diff) | |
| download | seaweedfs-c89b4fd18b80f04bdf229fdec570b5672223201f.tar.xz seaweedfs-c89b4fd18b80f04bdf229fdec570b5672223201f.zip | |
Add ParseUint64 function
Diffstat (limited to 'go/util/parse.go')
| -rw-r--r-- | go/util/parse.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/go/util/parse.go b/go/util/parse.go index 930da9522..0a8317c19 100644 --- a/go/util/parse.go +++ b/go/util/parse.go @@ -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 +} |
