internal/protocol/segment.go
func (h *segmentHeader) write(wr *bufio.Writer) error {
	wr.WriteInt32(h.segmentLength)
	wr.WriteInt32(h.segmentOfs)
	wr.WriteInt16(h.noOfParts)
	wr.WriteInt16(h.segmentNo)
	wr.WriteInt8(int8(h.segmentKind))

	switch h.segmentKind {

	default: //error
		wr.WriteZeroes(11) //segmentHeaderLength

	case skRequest:
		wr.WriteInt8(int8(h.messageType))
		wr.WriteBool(h.commit)
		wr.WriteInt8(int8(h.commandOptions))
		wr.WriteZeroes(8) //segmentHeaderSize

	case skReply:

		wr.WriteZeroes(1) //reserved
		wr.WriteInt16(int16(h.functionCode))
		wr.WriteZeroes(8) //segmentHeaderSize

	}

	if trace {
		outLogger.Printf("write segment header: %s", h)
	}

	return nil
}
func (h *segmentHeader) write(wr *bufio.Writer) error {
	wr.WriteInt32(h.segmentLength)
	wr.WriteInt32(h.segmentOfs)
	wr.WriteInt16(h.noOfParts)
	wr.WriteInt16(h.segmentNo)
	wr.WriteInt8(int8(h.segmentKind))

	switch h.segmentKind {

	default: //error
		wr.WriteZeroes(11) //segmentHeaderLength

	case skRequest:
		wr.WriteInt8(int8(h.messageType))
		wr.WriteBool(h.commit)
		wr.WriteInt8(int8(h.commandOptions))
		wr.WriteZeroes(8) //segmentHeaderSize

	case skReply:

		wr.WriteZeroes(1) //reserved
		wr.WriteInt16(int16(h.functionCode))
		wr.WriteZeroes(8) //segmentHeaderSize

	}

	if trace {
		outLogger.Printf("write segment header: %s", h)
	}

	return nil
}
func ( h * segmentHeader ) write ( wr * bufio . Writer ) error { wr . WriteInt32 ( h . segmentLength ) wr . WriteInt32 ( h . segmentOfs ) wr . WriteInt16 ( h . noOfParts ) wr . WriteInt16 ( h . segmentNo ) wr . WriteInt8 ( int8 ( h . segmentKind ) ) switch h . segmentKind { default : //error wr . WriteZeroes ( 11 ) //segmentHeaderLength case skRequest : wr . WriteInt8 ( int8 ( h . messageType ) ) wr . WriteBool ( h . commit ) wr . WriteInt8 ( int8 ( h . commandOptions ) ) wr . WriteZeroes ( 8 ) //segmentHeaderSize case skReply : wr . WriteZeroes ( 1 ) //reserved wr . WriteInt16 ( int16 ( h . functionCode ) ) wr . WriteZeroes ( 8 ) //segmentHeaderSize } if trace { outLogger . Printf ( " " , h ) } return nil }
//  request
request