// NextPart returns the next part in the multipart or an error.
// When there are no more parts, the error io.EOF is returned.
NextPart returns the next part in the multipart or an error.
When there are no more parts, the error io.EOF is returned.
// NextPart returns the next part in the multipart or an error . // When there are no more parts the error io . EOF is returned .
func (r *Reader) NextPart() (*Part, error) {
	if r.currentPart != nil {
		r.currentPart.Close()
	}
	expectNewPart := false
	for {
		line, err := r.bufReader.ReadSlice('\n')
		if err != nil {
			return nil, fmt.Errorf("multipart: NextPart: %v", err)
		}
		if r.isBoundaryDelimiterLine(line) {
			r.partsRead++
			bp, err := newPart(r)
			if err != nil {
				return nil, err
			}
			r.currentPart = bp
			return bp, nil
		}
		if hasPrefixThenNewline(line, r.dashBoundaryDash) {
			return nil, io.EOF
		}
		if expectNewPart {
			return nil, fmt.Errorf("multipart: expecting a new Part; got line %q", string(line))
		}
		if r.partsRead == 0 {
			continue
		}
		if bytes.Equal(line, r.nl) {
			expectNewPart = true
			continue
		}
		return nil, fmt.Errorf("multipart: unexpected line in Next(): %q", line)
	}
	panic("unreachable")
}
func ( r * Reader ) NextPart ( ) ( * Part , error ) { if r . currentPart != nil { r . currentPart . Close ( ) } expectNewPart := false for { line , err := r . bufReader . ReadSlice ( '\n' ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if r . isBoundaryDelimiterLine ( line ) { r . partsRead ++ bp , err := newPart ( r ) if err != nil { return nil , err } r . currentPart = bp return bp , nil } if hasPrefixThenNewline ( line , r . dashBoundaryDash ) { return nil , io . EOF } if expectNewPart { return nil , fmt . Errorf ( " " , string ( line ) ) } if r . partsRead == 0 { continue } if bytes . Equal ( line , r . nl ) { expectNewPart = true continue } return nil , fmt . Errorf ( " " , line ) } panic ( " " ) }
NextPart returns the next part in the multipart or an error.
NextPart returns the next part in the multipart or an error .
// Expected EOF // skip line // Consume the "\n" or "\r\n" separator between the // body of the previous part and the boundary line we // now expect will follow. (either a new part or the // end boundary)