Parse parses a bit array from the specified string.
(s string)
| 315 | |
| 316 | // Parse parses a bit array from the specified string. |
| 317 | func Parse(s string) (res BitArray, err error) { |
| 318 | if len(s) == 0 { |
| 319 | return res, nil |
| 320 | } |
| 321 | |
| 322 | if s[0] == 'x' || s[0] == 'X' { |
| 323 | return parseFromHex(s[1:]) |
| 324 | } |
| 325 | return parseFromBinary(s) |
| 326 | } |
| 327 | |
| 328 | func parseFromBinary(s string) (res BitArray, err error) { |
| 329 | words, lastBitsUsed := EncodingPartsForBitLen(uint(len(s))) |
no test coverage detected
searching dependent graphs…