GetBoolean returns the value retrieved by `Get`, cast to a bool if possible. The offset is the same as in `Get`. If key data type do not match, it will return error. SYS-REQ-005, SYS-REQ-079
(data []byte, keys ...string)
| 1304 | // If key data type do not match, it will return error. |
| 1305 | // SYS-REQ-005, SYS-REQ-079 |
| 1306 | func GetBoolean(data []byte, keys ...string) (val bool, err error) { |
| 1307 | v, t, _, e := Get(data, keys...) |
| 1308 | |
| 1309 | if e != nil { |
| 1310 | return false, e |
| 1311 | } |
| 1312 | |
| 1313 | if t != Boolean { |
| 1314 | if t == Null { |
| 1315 | return false, NullValueError |
| 1316 | } |
| 1317 | return false, fmt.Errorf("Value is not a boolean: %s", string(v)) |
| 1318 | } |
| 1319 | |
| 1320 | return ParseBoolean(v) |
| 1321 | } |
| 1322 | |
| 1323 | // ParseBoolean parses a Boolean ValueType into a Go bool (not particularly useful, but here for completeness) |
| 1324 | // SYS-REQ-012, SYS-REQ-036, SYS-REQ-057, SYS-REQ-066 |
searching dependent graphs…