refactor - pasdns can now look sane 3.0
This commit is contained in:
parent
57fbfbf059
commit
61f89c8067
7 changed files with 3 additions and 3 deletions
29
helper/read.go
Normal file
29
helper/read.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
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
|
||||
}
|
||||
|
||||
func ReadUntilNullString(reader *bufio.Reader) (string, error) {
|
||||
buf, err := ReadUntilNull(reader)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(buf), nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue