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)
| 1533 | // If key data type do not match, it will return an error. |
| 1534 | // SYS-REQ-003, SYS-REQ-075, SYS-REQ-076, SYS-REQ-077, SYS-REQ-078 |
| 1535 | func GetInt(data []byte, keys ...string) (val int64, err error) { |
| 1536 | v, t, _, e := Get(data, keys...) |
| 1537 | |
| 1538 | if e != nil { |
| 1539 | return 0, e |
| 1540 | } |
| 1541 | |
| 1542 | if t != Number { |
| 1543 | if t == Null { |
| 1544 | return 0, NullValueError |
| 1545 | } |
| 1546 | return 0, fmt.Errorf("Value is not a number: %s", string(v)) |
| 1547 | } |
| 1548 | |
| 1549 | return ParseInt(v) |
| 1550 | } |
| 1551 | |
| 1552 | // GetBoolean returns the value retrieved by `Get`, cast to a bool if possible. |
| 1553 | // The offset is the same as in `Get`. |