GetInt returns the value retrieved by `Get`, cast to a int64 if possible. If key data type do not match, it will return an error. SYS-REQ-003, SYS-REQ-075, SYS-REQ-076, SYS-REQ-077, SYS-REQ-078
(data []byte, keys ...string)
| 1283 | // If key data type do not match, it will return an error. |
| 1284 | // SYS-REQ-003, SYS-REQ-075, SYS-REQ-076, SYS-REQ-077, SYS-REQ-078 |
| 1285 | func GetInt(data []byte, keys ...string) (val int64, err error) { |
| 1286 | v, t, _, e := Get(data, keys...) |
| 1287 | |
| 1288 | if e != nil { |
| 1289 | return 0, e |
| 1290 | } |
| 1291 | |
| 1292 | if t != Number { |
| 1293 | if t == Null { |
| 1294 | return 0, NullValueError |
| 1295 | } |
| 1296 | return 0, fmt.Errorf("Value is not a number: %s", string(v)) |
| 1297 | } |
| 1298 | |
| 1299 | return ParseInt(v) |
| 1300 | } |
| 1301 | |
| 1302 | // GetBoolean returns the value retrieved by `Get`, cast to a bool if possible. |
| 1303 | // The offset is the same as in `Get`. |
searching dependent graphs…