New constructs a Printer whose Color flag follows the standard auto-detect rules. nil writers fall back to os.Stdout / os.Stderr.
(out, err io.Writer)
| 25 | // New constructs a Printer whose Color flag follows the standard auto-detect |
| 26 | // rules. nil writers fall back to os.Stdout / os.Stderr. |
| 27 | func New(out, err io.Writer) *Printer { |
| 28 | if out == nil { |
| 29 | out = os.Stdout |
| 30 | } |
| 31 | if err == nil { |
| 32 | err = os.Stderr |
| 33 | } |
| 34 | return &Printer{Out: out, Err: err, Color: detectColor(out)} |
| 35 | } |
| 36 | |
| 37 | func detectColor(w io.Writer) bool { |
| 38 | if os.Getenv("NO_COLOR") != "" { |