You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
249 B

  1. package util
  2. import (
  3. "strconv"
  4. )
  5. func ParseInt(text string, defaultValue int) int {
  6. count, parseError := strconv.ParseUint(text, 10, 64)
  7. if parseError != nil {
  8. if len(text) > 0 {
  9. return 0
  10. }
  11. return defaultValue
  12. }
  13. return int(count)
  14. }