Fprint formats using the default formats for its operands and writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
(writer io.Writer, a ...any)
| 103 | // Spaces are added between operands when neither is a string. |
| 104 | // It returns the number of bytes written and any write error encountered. |
| 105 | func Fprint(writer io.Writer, a ...any) { |
| 106 | if !Output { |
| 107 | return |
| 108 | } |
| 109 | |
| 110 | var ret string |
| 111 | var printed bool |
| 112 | |
| 113 | for _, bar := range ActiveProgressBarPrinters { |
| 114 | if bar.IsActive && (bar.Writer == writer || bar.Writer == os.Stderr) { |
| 115 | ret += sClearLine() |
| 116 | ret += Sprinto(a...) |
| 117 | printed = true |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | for _, spinner := range activeSpinnerPrinters { |
| 122 | if spinner.IsActive && (spinner.Writer == writer || spinner.Writer == os.Stderr) { |
| 123 | ret += sClearLine() |
| 124 | |
| 125 | ret += Sprinto(a...) |
| 126 | printed = true |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if !printed { |
| 131 | ret = color.Sprint(Sprint(a...)) |
| 132 | } |
| 133 | |
| 134 | if writer != nil { |
| 135 | color.Fprint(writer, Sprint(ret)) |
| 136 | } else { |
| 137 | color.Print(Sprint(ret)) |
| 138 | } |
| 139 | |
| 140 | // Refresh all progressbars in case they were overwritten previously. Reference: #302 |
| 141 | for _, bar := range ActiveProgressBarPrinters { |
| 142 | if bar.IsActive { |
| 143 | bar.UpdateTitle(bar.Title) |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // Fprintln formats using the default formats for its operands and writes to w. |
| 149 | // Spaces are always added between operands and a newline is appended. |
searching dependent graphs…