aboutsummaryrefslogtreecommitdiff
path: root/go/util/parse.go
blob: 930da952230771843d85dbbaf9bf88a6b75d2c63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)
}