aboutsummaryrefslogtreecommitdiff
path: root/weed/util/parse.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2013-02-10 03:25:35 -0800
committerChris Lu <chris.lu@gmail.com>2013-02-10 03:25:35 -0800
commitab6fb13ad795763ba7fc7c91696d2890be6da543 (patch)
tree3d956452bdcef7ea4b50457faff07df06f8d4346 /weed/util/parse.go
parent1b6f53cdac9a44370f67276ede138f5cde8806c2 (diff)
downloadseaweedfs-ab6fb13ad795763ba7fc7c91696d2890be6da543.tar.xz
seaweedfs-ab6fb13ad795763ba7fc7c91696d2890be6da543.zip
avoid the "src" folder
Diffstat (limited to 'weed/util/parse.go')
-rw-r--r--weed/util/parse.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/weed/util/parse.go b/weed/util/parse.go
new file mode 100644
index 000000000..930da9522
--- /dev/null
+++ b/weed/util/parse.go
@@ -0,0 +1,16 @@
+package util
+
+import (
+ "strconv"
+)
+
+func ParseInt(text string, defaultValue int) int {
+ count, parseError := strconv.ParseUint(text, 10, 64)
+ if parseError != nil {
+ if len(text) > 0 {
+ return 0
+ }
+ return defaultValue
+ }
+ return int(count)
+}