code: func strToInt(str string) (int64, error) {
  	str = strings.TrimSpace(str)
  	if len(str) == 0 {
  		return 0, nil
  	}
  	negative := false
  	i := 0
  	if str[i] == '-' {
  		negative = true
  		i++
  	} else if str[i] == '+' {
  		i++
  	}
  	r := int64(0)
  	for ; i < len(str); i++ {
  		if !unicode.IsDigit(rune(str[i])) {
  			break
  		}
  		r = r*10 + int64(str[i]-'0')
  	}
  	if negative {
  		r = -r
  	}
  	// TODO: if i < len(str), we should return an error.
  	return r, nil
  }
docs: // strToInt converts a string to an integer in best effort.
  // TODO: handle overflow and add unittest.