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)
| 2085 | // values larger than uint64 return OverflowIntegerError. |
| 2086 | // SYS-REQ-003 |
| 2087 | func GetUint64(data []byte, keys ...string) (uint64, error) { |
| 2088 | v, t, _, _, err := internalGet(data, keys...) |
| 2089 | if err != nil { |
| 2090 | return 0, err |
| 2091 | } |
| 2092 | |
| 2093 | if t != Number { |
| 2094 | if t == Null { |
| 2095 | return 0, NullValueError |
| 2096 | } |
| 2097 | return 0, fmt.Errorf("Value is not a number: %s", string(v)) |
| 2098 | } |
| 2099 | |
| 2100 | if n, ok, _ := parseInt(v); ok { |
| 2101 | if n < 0 { |
| 2102 | return 0, MalformedValueError |
| 2103 | } |
| 2104 | return uint64(n), nil |
| 2105 | } |
| 2106 | |
| 2107 | n, parseErr := strconv.ParseUint(string(v), 10, 64) |
| 2108 | if parseErr == nil { |
| 2109 | return n, nil |
| 2110 | } |
| 2111 | |
| 2112 | var numErr *strconv.NumError |
| 2113 | if errors.As(parseErr, &numErr) && numErr.Err == strconv.ErrRange { |
| 2114 | return 0, OverflowIntegerError |
| 2115 | } |
| 2116 | return 0, MalformedValueError |
| 2117 | } |
| 2118 | |
| 2119 | // SYS-REQ-112 |
| 2120 | func containerStart(data []byte, open byte, keys ...string) (int, error) { |