(s string)
| 2780 | } |
| 2781 | |
| 2782 | func parseInt(s string) (n int64, ok bool) { |
| 2783 | var i int |
| 2784 | var sign bool |
| 2785 | if len(s) > 0 && s[0] == '-' { |
| 2786 | sign = true |
| 2787 | i++ |
| 2788 | } |
| 2789 | if i == len(s) { |
| 2790 | return 0, false |
| 2791 | } |
| 2792 | for ; i < len(s); i++ { |
| 2793 | if s[i] >= '0' && s[i] <= '9' { |
| 2794 | n = n*10 + int64(s[i]-'0') |
| 2795 | } else { |
| 2796 | return 0, false |
| 2797 | } |
| 2798 | } |
| 2799 | if sign { |
| 2800 | return n * -1, true |
| 2801 | } |
| 2802 | return n, true |
| 2803 | } |
| 2804 | |
| 2805 | // safeInt validates a given JSON number |
| 2806 | // ensures it lies within the minimum and maximum representable JSON numbers |
no outgoing calls
no test coverage detected
searching dependent graphs…