func (p *PairScanner) Err() error {
	if err := p.r1.Err(); err != nil {
		return err
	}
	if err := p.r2.Err(); err != nil {
		return err
	}
	return p.err
}
Err returns the scanning error, if any. It should be checked
after Scan returns false.
package fastq
import (
	"bufio"
	"errors"
	"io"
)
var (
	ErrShort = errors.New("short FASTQ file")
	ErrInvalid = errors.New("invalid FASTQ file")
	ErrDiscordant = errors.New("discordant FASTQ pairs")
)
type Read struct {
	ID, Seq, Unk, Qual string
}
func (r *Read) Trim(n int) {
	r.Seq = r.Seq[:n]
	r.Qual = r.Qual[:n]
}
var errEOF = errors.New("eof")
type Scanner struct {
	b      *bufio.Scanner
	err    error
	fields Field
}
type Field uint
const (
	ID Field = 1 << iota
	Seq
	Unk
	Qual
	All = ID | Seq | Unk | Qual
)
func NewScanner(r io.Reader, fields Field) *Scanner {
	return &Scanner{b: bufio.NewScanner(r), fields: fields}
}
func (f *Scanner) Scan(read *Read) bool {
	if f.err != nil {
		return false
	}
	if !f.b.Scan() {
		if f.err = f.b.Err(); f.err == nil {
			f.err = errEOF
		}
		return false
	}
	id := f.b.Bytes()
	if len(id) == 0 || id[0] != '@' {
		f.err = ErrInvalid
		return false
	}
	if f.fields&ID != 0 {
		read.ID = string(id)
	}
	if !f.scan() {
		return false
	}
	if f.fields&Seq != 0 {
		read.Seq = f.b.Text()
	}
	if !f.scan() {
		return false
	}
	unk := f.b.Bytes()
	if len(unk) == 0 || unk[0] != '+' {
		f.err = ErrInvalid
		return false
	}
	if f.fields&Unk != 0 {
		read.Unk = string(unk)
	}
	if !f.scan() {
		return false
	}
	if f.fields&Qual != 0 {
		read.Qual = f.b.Text()
	}
	return true
}
func (f *Scanner) scan() bool {
	ok := f.b.Scan()
	if !ok {
		if f.err = f.b.Err(); f.err == nil {
			f.err = ErrShort
		}
	}
	return ok
}
func (f *Scanner) Err() error {
	if f.err == errEOF {
		return nil
	}
	return f.err
}
type PairScanner struct {
	r1, r2 *Scanner
	err    error
}
func NewPairScanner(r1, r2 io.Reader, fields Field) *PairScanner {
	return &PairScanner{
		r1: NewScanner(r1, fields),
		r2: NewScanner(r2, fields),
	}
}
func (p *PairScanner) Scan(r1, r2 *Read) bool {
	ok1 := p.r1.Scan(r1)
	ok2 := p.r2.Scan(r2)
	if ok1 != ok2 {
		p.err = ErrDiscordant
	}
	return ok1 && ok2
}