func (c *Collector) Done() error {
	c.done = true
	return c.erorr()
}
Done ends collection and returns the collected error(s).
package warnings  
import (
	"bytes"
	"fmt"
)
type List struct {
	Warnings []error
	Fatal    error
}
func (l List) Error() string {
	b := bytes.NewBuffer(nil)
	if l.Fatal != nil {
		fmt.Fprintln(b, "fatal:")
		fmt.Fprintln(b, l.Fatal)
	}
	switch len(l.Warnings) {
	case 0:
	case 1:
		fmt.Fprintln(b, "warning:")
	default:
		fmt.Fprintln(b, "warnings:")
	}
	for _, err := range l.Warnings {
		fmt.Fprintln(b, err)
	}
	return b.String()
}
type Collector struct {
	IsFatal func(error) bool
	FatalWithWarnings bool
	l    List
	done bool
}
func NewCollector(isFatal func(error) bool) *Collector {
	return &Collector{IsFatal: isFatal}
}
func (c *Collector) Collect(err error) error {
	if c.done {
		panic("warnings.Collector already done")
	}
	if err == nil {
		return nil
	}
	if c.IsFatal(err) {
		c.done = true
		c.l.Fatal = err
	} else {
		c.l.Warnings = append(c.l.Warnings, err)
	}
	if c.l.Fatal != nil {
		return c.erorr()
	}
	return nil
}