Created
March 4, 2022 21:41
-
-
Save markbates/2052b33342cb94f6a6bcbfac16f5c69b to your computer and use it in GitHub Desktop.
Revisions
-
markbates created this gist
Mar 4, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ package cli import ( "io" "os" ) // IO represents the standard input, output, and error stream. type IO struct { In io.Reader // standard input Out io.Writer // standard output Err io.Writer // standard error } // Stdout returns IO.In. // Defaults to os.Stdout. func (oi IO) Stdout() io.Writer { if oi.Out == nil { return os.Stdout } return oi.Out } // Stderr returns IO.Err. // Defaults to os.Stderr. func (oi IO) Stderr() io.Writer { if oi.Err == nil { return os.Stderr } return oi.Err } // Stdin returns IO.In. // Defaults to os.Stdin. func (oi IO) Stdin() io.Reader { if oi.In == nil { return os.Stdin } return oi.In }