just return if Writer is nil
Vladimir Bauer
8 years ago
| 1 | 1 | |
| 2 | 2 | import ( |
| 3 | 3 | "io" |
| 4 | "io/ioutil" | |
| 5 | 4 | "sync" |
| 6 | 5 | "time" |
| 7 | 6 | "unicode/utf8" |
| 72 | 71 | func WithOutput(w io.Writer) ProgressOption { |
| 73 | 72 | return func(s *pState) { |
| 74 | 73 | if w == nil { |
| 75 | w = ioutil.Discard | |
| 74 | return | |
| 76 | 75 | } |
| 77 | 76 | s.cw = cwriter.New(w) |
| 78 | 77 | } |
| 82 | 81 | func WithDebugOutput(w io.Writer) ProgressOption { |
| 83 | 82 | return func(s *pState) { |
| 84 | 83 | if w == nil { |
| 85 | w = ioutil.Discard | |
| 84 | return | |
| 86 | 85 | } |
| 87 | 86 | s.debugOut = w |
| 88 | 87 | } |