(size int)
| 106 | } |
| 107 | |
| 108 | func RandomBuf(size int) ([]byte, error) { |
| 109 | buf := make([]byte, size) |
| 110 | |
| 111 | if _, err := io.ReadFull(rand.Reader, buf); err != nil { |
| 112 | return nil, errors.Trace(err) |
| 113 | } |
| 114 | |
| 115 | // avoid to generate '\0' |
| 116 | for i, b := range buf { |
| 117 | if b == 0 { |
| 118 | buf[i] = '0' |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | return buf, nil |
| 123 | } |
| 124 | |
| 125 | // FixedLengthInt: little endian |
| 126 | func FixedLengthInt(buf []byte) uint64 { |
no outgoing calls
no test coverage detected