GetUint64 returns the value retrieved by internalGet, cast to a uint64 if possible. Negative values and malformed integers return MalformedValueError; values larger than uint64 return OverflowIntegerError. SYS-REQ-003
(data []byte, keys ...string)
| 2198 | // values larger than uint64 return OverflowIntegerError. |
| 2199 | // SYS-REQ-003 |
| 2200 | func GetUint64(data []byte, keys ...string) (uint64, error) { |
| 2201 | v, t, _, _, err := internalGet(data, keys...) |
| 2202 | if err != nil { |
| 2203 | return 0, err |
| 2204 | } |
| 2205 | |
| 2206 | if t != Number { |
| 2207 | if t == Null { |
| 2208 | return 0, NullValueError |
| 2209 | } |
| 2210 | return 0, fmt.Errorf("Value is not a number: %s", string(v)) |
| 2211 | } |
| 2212 | |
| 2213 | if n, ok, _ := parseInt(v); ok { |
| 2214 | if n < 0 { |
| 2215 | return 0, MalformedValueError |
| 2216 | } |
| 2217 | return uint64(n), nil |
| 2218 | } |
| 2219 | |
| 2220 | n, parseErr := strconv.ParseUint(string(v), 10, 64) |
| 2221 | if parseErr == nil { |
| 2222 | return n, nil |
| 2223 | } |
| 2224 | |
| 2225 | var numErr *strconv.NumError |
| 2226 | if errors.As(parseErr, &numErr) && numErr.Err == strconv.ErrRange { |
| 2227 | return 0, OverflowIntegerError |
| 2228 | } |
| 2229 | return 0, MalformedValueError |
| 2230 | } |
| 2231 | |
| 2232 | // SYS-REQ-112 |
| 2233 | func containerStart(data []byte, open byte, keys ...string) (int, error) { |