parse config一处判断无效value

This commit is contained in:
dexter
2023-02-15 09:35:00 +08:00
parent 04976bac16
commit 10a188a1ac
5 changed files with 21 additions and 5 deletions

View File

@@ -2,12 +2,23 @@ package util
import (
"encoding/binary"
"io"
"math"
"net"
)
type Buffer []byte
func (b *Buffer) Read(buf []byte) (n int, err error) {
if !b.CanReadN(len(buf)) {
copy(buf, *b)
return b.Len(), io.EOF
}
ret := b.ReadN(len(buf))
copy(buf, ret)
return len(ret), err
}
func (b *Buffer) ReadN(n int) Buffer {
l := b.Len()
r := (*b)[:n]