func (r *ProtocolV2Response) Scan() bool {
	if r.err != nil || r.state == protocolV2ResponseStateEnd {
		return false
	}
	if !r.scanner.Scan() {
		r.err = r.scanner.Err()
		if r.err == nil && r.state != protocolV2ResponseStateBegin {
			r.err = SyntaxError("early EOF")
		}
		return false
	}
	switch p := r.scanner.Packet().(type) {
	case FlushPacket:
		r.state = protocolV2ResponseStateBegin
		r.curr = &ProtocolV2ResponseChunk{
			EndResponse: true,
		}
		return true
	case DelimPacket:
		r.state = protocolV2ResponseStateScanResponse
		r.curr = &ProtocolV2ResponseChunk{
			Delimiter: true,
		}
		return true
	case BytesPacket:
		r.state = protocolV2ResponseStateScanResponse
		r.curr = &ProtocolV2ResponseChunk{
			Response: p,
		}
		return true
	default:
		r.err = SyntaxError(fmt.Sprintf("unexpected packet: %#v", r.scanner.Packet()))
		return false
	}
}
Scan advances the scanner to the next packet. It returns false when the scan
stops, either by reaching the end of the input or an error. After scan
returns false, the Err method will return any error that occurred during
scanning, except that if it was io.EOF, Err will return nil.
package gitprotocolio
import (
	"fmt"
	"io"
)
type protocolV2ResponseState int
const (
	protocolV2ResponseStateBegin protocolV2ResponseState = iota
	protocolV2ResponseStateScanResponse
	protocolV2ResponseStateEnd
)
type ProtocolV2ResponseChunk struct {
	Response    []byte
	Delimiter   bool
	EndResponse bool
}
func (c *ProtocolV2ResponseChunk) EncodeToPktLine() []byte {
	if len(c.Response) != 0 {
		return BytesPacket(c.Response).EncodeToPktLine()
	}
	if c.Delimiter {
		return DelimPacket{}.EncodeToPktLine()
	}
	if c.EndResponse {
		return FlushPacket{}.EncodeToPktLine()
	}
	panic("impossible chunk")
}
type ProtocolV2Response struct {
	scanner *PacketScanner
	state   protocolV2ResponseState
	err     error
	curr    *ProtocolV2ResponseChunk
}
func NewProtocolV2Response(rd io.Reader) *ProtocolV2Response {
	return &ProtocolV2Response{scanner: NewPacketScanner(rd)}
}
func (r *ProtocolV2Response) Err() error {
	return r.err
}
func (r *ProtocolV2Response) Chunk() *ProtocolV2ResponseChunk {
	return r.curr
}