(n uint64)
| 171 | } |
| 172 | |
| 173 | func PutLengthEncodedInt(n uint64) []byte { |
| 174 | switch { |
| 175 | case n <= 250: |
| 176 | return []byte{byte(n)} |
| 177 | |
| 178 | case n <= 0xffff: |
| 179 | return []byte{0xfc, byte(n), byte(n >> 8)} |
| 180 | |
| 181 | case n <= 0xffffff: |
| 182 | return []byte{0xfd, byte(n), byte(n >> 8), byte(n >> 16)} |
| 183 | |
| 184 | case n <= 0xffffffffffffffff: |
| 185 | return []byte{ |
| 186 | 0xfe, byte(n), byte(n >> 8), byte(n >> 16), byte(n >> 24), |
| 187 | byte(n >> 32), byte(n >> 40), byte(n >> 48), byte(n >> 56), |
| 188 | } |
| 189 | } |
| 190 | return nil |
| 191 | } |
| 192 | |
| 193 | // LengthEncodedString returns the string read as a bytes slice, whether the value is NULL, |
| 194 | // the number of bytes read and an error, in case the string is longer than |
no outgoing calls
no test coverage detected