// ReadLine reads a line from the input and processes it.
//
// This function will read exactly 1 line from the input Reader, and do one of
// a few things depending on state and the value of the line.
// If no Message is currently being parsed, then this method will attempt to
// read a header line and start a new Message instance.
// If there is a Message being processed, then it will attempt to parse the
// line as a Field (Name: Value). If the line is empty, then the message is
// considered done and is returned.
ReadLine reads a line from the input and processes it.

This function will read exactly 1 line from the input Reader, and do one of
a few things depending on state and the value of the line.
If no Message is currently being parsed, then this method will attempt to
read a header line and start a new Message instance.
If there is a Message being processed, then it will attempt to parse the
line as a Field (Name: Value). If the line is empty, then the message is
considered done and is returned.
// ReadLine reads a line from the input and processes it . // // This function will read exactly 1 line from the input Reader and do one of // a few things depending on state and the value of the line . // If no Message is currently being parsed then this method will attempt to // read a header line and start a new Message instance . // If there is a Message being processed then it will attempt to parse the // line as a Field ( Name : Value ) . If the line is empty then the message is // considered done and is returned .
func (r *MessageReader) ReadLine() (*Message, error) {
	if r.message == nil {
		msg, err := r.readHeader()
		if err != nil {
			return nil, err
		}
		r.message = msg
		return nil, nil
	}
	line, err := r.reader.ReadString('\n')
	if err != nil {
		return r.commitMessage(nil), err
	}
	line = strings.TrimSpace(line)
	if line == "" {
		return r.commitMessage(nil), nil
	}
	parts := strings.SplitN(line, ":", 2)
	if len(parts) != 2 {
		msg, err := ParseHeader(line)
		if err != nil {
			return nil, fmt.Errorf("invalid field format in \"%s\"", line)
		}
		return r.commitMessage(msg), errors.New("new message started without old message ending")
	}
	key := strings.TrimSpace(parts[0])
	value := strings.TrimSpace(parts[1])
	r.message.Fields[key] = value
	return nil, nil
}
func ( r * MessageReader ) ReadLine ( ) ( * Message , error ) { if r . message == nil { msg , err := r . readHeader ( ) if err != nil { return nil , err } r . message = msg return nil , nil } line , err := r . reader . ReadString ( '\n' ) if err != nil { return r . commitMessage ( nil ) , err } line = strings . TrimSpace ( line ) if line == " " { return r . commitMessage ( nil ) , nil } parts := strings . SplitN ( line , " " , 2 ) if len ( parts ) != 2 { msg , err := ParseHeader ( line ) if err != nil { return nil , fmt . Errorf ( " \" \" " , line ) } return r . commitMessage ( msg ) , errors . New ( " " ) } key := strings . TrimSpace ( parts [ 0 ] ) value := strings . TrimSpace ( parts [ 1 ] ) r . message . Fields [ key ] = value return nil , nil }
ReadLine reads a line from the input and processes it.
ReadLine reads a line from the input and processes it .
// EOF or other stream error // Blank line in input signals end of message // Bad field format - continue parsing? // Test for header