fix documentation of Command.SetOut method

The statement "If newOut is nil, os.Stdout is used" was misleading as
`Command.Print` prints to os.Stderr when `outWriter = nil`

As the default is based on which one of `OutOrStdout` or `OutOrStderr`
is used, i.e. there is no default.
This commit is contained in:
Kanak Singhal 2023-10-04 15:02:43 +00:00
parent bd4d1655f6
commit 5975d90254

View file

@ -273,7 +273,6 @@ func (c *Command) SetArgs(a []string) {
} }
// SetOutput sets the destination for usage and error messages. // SetOutput sets the destination for usage and error messages.
// If output is nil, os.Stderr is used.
// Deprecated: Use SetOut and/or SetErr instead // Deprecated: Use SetOut and/or SetErr instead
func (c *Command) SetOutput(output io.Writer) { func (c *Command) SetOutput(output io.Writer) {
c.outWriter = output c.outWriter = output
@ -281,19 +280,16 @@ func (c *Command) SetOutput(output io.Writer) {
} }
// SetOut sets the destination for usage messages. // SetOut sets the destination for usage messages.
// If newOut is nil, os.Stdout is used.
func (c *Command) SetOut(newOut io.Writer) { func (c *Command) SetOut(newOut io.Writer) {
c.outWriter = newOut c.outWriter = newOut
} }
// SetErr sets the destination for error messages. // SetErr sets the destination for error messages.
// If newErr is nil, os.Stderr is used.
func (c *Command) SetErr(newErr io.Writer) { func (c *Command) SetErr(newErr io.Writer) {
c.errWriter = newErr c.errWriter = newErr
} }
// SetIn sets the source for input data // SetIn sets the source for input data
// If newIn is nil, os.Stdin is used.
func (c *Command) SetIn(newIn io.Reader) { func (c *Command) SetIn(newIn io.Reader) {
c.inReader = newIn c.inReader = newIn
} }