func (h *ErrorVector) GetErrorList(mode int) ErrorList {
	if len(h.errors) == 0 {
		return nil
	}
	list := make(ErrorList, len(h.errors))
	copy(list, h.errors)
	if mode >= Sorted {
		sort.Sort(list)
	}
	if mode >= NoMultiples {
		var last token.Position  
		i := 0
		for _, e := range list {
			if e.Pos.Filename != last.Filename || e.Pos.Line != last.Line {
				last = e.Pos
				list[i] = e
				i++
			}
		}
		list = list[0:i]
	}
	return list
}
GetErrorList returns the list of errors collected by an ErrorVector.
The construction of the ErrorList returned is controlled by the mode
parameter. If there are no errors, the result is nil.
package scanner
import (
	"fmt"
	"io"
	"sort"
	"github.com/rogpeppe/godef/go/token"
)
type ErrorHandler interface {
	Error(pos token.Position, msg string)
}
type ErrorVector struct {
	errors []*Error
}
func (h *ErrorVector) Reset() { h.errors = h.errors[:0] }
func (h *ErrorVector) ErrorCount() int { return len(h.errors) }
type Error struct {
	Pos token.Position
	Msg string
}
func (e *Error) Error() string {
	if e.Pos.Filename != "" || e.Pos.IsValid() {
		return e.Pos.String() + ": " + e.Msg
	}
	return e.Msg
}
type ErrorList []*Error
func (p ErrorList) Len() int      { return len(p) }
func (p ErrorList) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func (p ErrorList) Less(i, j int) bool {
	e := &p[i].Pos
	f := &p[j].Pos
	if e.Filename < f.Filename {
		return true
	}
	if e.Filename == f.Filename {
		if e.Line < f.Line {
			return true
		}
		if e.Line == f.Line {
			return e.Column < f.Column
		}
	}
	return false
}
func (p ErrorList) Error() string {
	switch len(p) {
	case 0:
		return "unspecified error"
	case 1:
		return p[0].Error()
	}
	return fmt.Sprintf("%s (and %d more errors)", p[0].Error(), len(p)-1)
}
const (
	Raw         = iota  
	Sorted              
	NoMultiples         
)