meow purrr :3
This commit is contained in:
parent
3fb5fc9033
commit
aff3757618
5 changed files with 93 additions and 0 deletions
21
src/helper/read.go
Normal file
21
src/helper/read.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package helper
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
)
|
||||
|
||||
func ReadUntilNull(reader *bufio.Reader) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
for {
|
||||
b, err := reader.ReadByte()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if b == byte(rune(0)) {
|
||||
break
|
||||
}
|
||||
buf.WriteByte(b)
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue