v0.0.4
新增TwoBuf数据结构
tb := NewTwoBuf()
// 取右边buffer
buf := tb.Right()
//模拟从异步io里面填充一块buffer
n, err := r.Read(buf)
if err == io.EOF {
break
}
// 把溢出数据包含进来
// 左边放需要重新解析数据,右边放新塞的buffer
currSentData := tb.All(n)
//解析
success, err := p.Execute(&setting, currSentData)
if err != nil {
//panic(err.Error() + fmt.Sprintf(" size:%d", size))
}
if success != len(currSentData) {
// 测试用, 把送入解析器的buffer累加起来,最后验证下数据送得对不对
totalSentBuf = append(totalSentBuf, currSentData[:success]...)
tb.MoveLeft(currSentData[success:])
} else {
// 测试用
totalSentBuf = append(totalSentBuf, currSentData...)
tb.Reset()
}