Documentation ¶
Overview ¶
Package pktline reads and writes the pkt-line format described in https://git-scm.com/docs/protocol-common#_pkt_line_format.
Index ¶
Constants ¶
const MaxSize = 65516
MaxSize is the maximum number of bytes permitted in a single pkt-line.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
Append appends a data-pkt to dst with the given data. It panics if len(line) == 0 or len(line) > MaxSize.
func AppendString ¶
AppendString appends a data-pkt to dst with the given data. It panics if len(line) == 0 or len(line) > MaxSize.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads pkt-lines from an io.Reader object. It does not perform any internal buffering and does not read any more bytes than requested.
func (*Reader) Bytes ¶
Bytes returns the data of the most recent packet read by a call to Next. It returns an error if Next returned false or the most recent packet is not a Data packet. The underlying array may point to data that will be overwritten by a subsequent call to Next.
func (*Reader) Next ¶
Next advances the Reader to the next pkt-line, which will then be available through the Bytes or Text methods. It returns false when the Reader encounters an error. After Next returns false, the Err method will return any error that occurred while reading.
func (*Reader) Text ¶
Text returns the data of the most recent packet read by a call to Next, stripping the trailing line-feed ('\n') if present. It returns an error if Next returned false or the most recent packet is not a Data packet. The underlying array may point to data that will be overwritten by a subsequent call to Next.
type Type ¶
type Type int8
Type indicates the type of a packet.
const ( // Flush indicates the end of a message. Flush Type = 0 // Delim indicates the end of a section in the Version 2 protocol. // https://git-scm.com/docs/protocol-v2#_packet_line_framing Delim Type = 1 // Data indicates a packet with data. Data Type = 4 )
Packet types.