DecodeRawBytesToByteArrayAuto detects which format to use with DecodeRawBytesToByteArray(). It only supports hex ("\x" prefix) and escape.
(data []byte)
| 212 | // DecodeRawBytesToByteArray(). It only supports hex ("\x" prefix) |
| 213 | // and escape. |
| 214 | func DecodeRawBytesToByteArrayAuto(data []byte) ([]byte, error) { |
| 215 | if len(data) >= 2 && data[0] == '\\' && (data[1] == 'x' || data[1] == 'X') { |
| 216 | return DecodeRawBytesToByteArray(data[2:], BytesEncodeHex) |
| 217 | } |
| 218 | return DecodeRawBytesToByteArray(data, BytesEncodeEscape) |
| 219 | } |
| 220 | |
| 221 | func (f BytesEncodeFormat) String() string { |
| 222 | switch f { |
no test coverage detected
searching dependent graphs…