From b278bfac94ca650c37c8db6b653428db4a02e46a Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Thu, 7 Sep 2017 14:32:01 +0100 Subject: [PATCH] main: Introduce defaultErrorFile Add a "defaultErrorFile" variable for parity with "defaultOutputFile" and to allow testing the fatal() function (which now uses defaultErrorFile). Signed-off-by: James O. D. Hunt --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index ff0df7c2..291d6754 100644 --- a/main.go +++ b/main.go @@ -62,6 +62,10 @@ var vci vc.VC = virtcontainersImpl // information to. var defaultOutputFile = os.Stdout +// defaultErrorFile is the default output file to write error +// messages to. +var defaultErrorFile = os.Stderr + func beforeSubcommands(context *cli.Context) error { if userWantsUsage(context) || (context.NArg() == 1 && (context.Args()[0] == "cc-check")) { // No setup required if the user just @@ -216,7 +220,7 @@ func userWantsUsage(context *cli.Context) bool { // fatal prints the error's details exits the program. func fatal(err error) { ccLog.Error(err) - fmt.Fprintln(os.Stderr, err) + fmt.Fprintln(defaultErrorFile, err) exit(1) }