Provide a variable for writing output with a default of os.Stderr

This commit is contained in:
Matt Farina
2016-05-05 10:26:53 -04:00
parent 75b97d09d9
commit 2a256d4c53
4 changed files with 10 additions and 6 deletions

View File

@@ -8,6 +8,10 @@ import (
var OsExiter = os.Exit
// OutWriter is used to write output to the user. This can be anything
// implementing the io.Writer interface and defaults to os.Stderr.
var OutWriter = os.Stderr
type MultiError struct {
Errors []error
}
@@ -69,7 +73,7 @@ func HandleExitCoder(err error) {
if exitErr, ok := err.(ExitCoder); ok {
if err.Error() != "" {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(OutWriter, err)
}
OsExiter(exitErr.ExitCode())
return