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)
| 1972 | // If key data type do not match, it will return an error. |
| 1973 | // SYS-REQ-003, SYS-REQ-075, SYS-REQ-076, SYS-REQ-077, SYS-REQ-078 |
| 1974 | func GetInt(data []byte, keys ...string) (val int64, err error) { |
| 1975 | v, t, _, e := Get(data, keys...) |
| 1976 | |
| 1977 | if e != nil { |
| 1978 | return 0, e |
| 1979 | } |
| 1980 | |
| 1981 | if t != Number { |
| 1982 | if t == Null { |
| 1983 | return 0, NullValueError |
| 1984 | } |
| 1985 | return 0, fmt.Errorf("Value is not a number: %s", string(v)) |
| 1986 | } |
| 1987 | |
| 1988 | return ParseInt(v) |
| 1989 | } |
| 1990 | |
| 1991 | // GetBoolean returns the value retrieved by `Get`, cast to a bool if possible. |
| 1992 | // The offset is the same as in `Get`. |