func HandleExitCoder(err error) {
	if err == nil {
		return
	}
	if exitErr, ok := err.(ExitCoder); ok {
		if err.Error() != "" {
			fmt.Fprintln(ErrWriter, err)
		}
		OsExiter(exitErr.ExitCode())
		return
	}
	if multiErr, ok := err.(MultiError); ok {
		for _, merr := range multiErr.Errors {
			HandleExitCoder(merr)
		}
	}
}
HandleExitCoder checks if the error fulfills the ExitCoder interface, and if
so prints the error to stderr (if it is non-empty) and calls OsExiter with the
given exit code.  If the given error is a MultiError, then this func is
called on all members of the Errors slice.
package cli
import (
	"fmt"
	"io"
	"os"
	"strings"
)
var OsExiter = os.Exit
var ErrWriter io.Writer = os.Stderr
type MultiError struct {
	Errors []error
}
func NewMultiError(err ...error) MultiError {
	return MultiError{Errors: err}
}
func (m MultiError) Error() string {
	errs := make([]string, len(m.Errors))
	for i, err := range m.Errors {
		errs[i] = err.Error()
	}
	return strings.Join(errs, "\n")
}
type ExitCoder interface {
	error
	ExitCode() int
}
type ExitError struct {
	exitCode int
	message  string
}
func NewExitError(message string, exitCode int) *ExitError {
	return &ExitError{
		exitCode: exitCode,
		message:  message,
	}
}
func (ee *ExitError) Error() string {
	return ee.message
}
func (ee *ExitError) ExitCode() int {
	return ee.exitCode
}