parenthesis are not necessary
Vladimir Bauer
7 years ago
| 97 | 97 | // FormatMsg formats final message according to WC.W and WC.C. |
| 98 | 98 | // Should be called by any Decorator implementation. |
| 99 | 99 | func (wc WC) FormatMsg(msg string, widthAccumulator chan<- int, widthDistributor <-chan int) string { |
| 100 | if (wc.C & DSyncWidth) != 0 { | |
| 100 | if wc.C&DSyncWidth != 0 { | |
| 101 | 101 | widthAccumulator <- utf8.RuneCountInString(msg) |
| 102 | 102 | max := <-widthDistributor |
| 103 | 103 | if max == 0 { |
| 104 | 104 | max = wc.W |
| 105 | 105 | } |
| 106 | if (wc.C & DextraSpace) != 0 { | |
| 106 | if wc.C&DextraSpace != 0 { | |
| 107 | 107 | max++ |
| 108 | 108 | } |
| 109 | 109 | return fmt.Sprintf(fmt.Sprintf(wc.format, max), msg) |
| 114 | 114 | // BuildFormat builds initial format according to WC.C |
| 115 | 115 | func (wc *WC) BuildFormat() { |
| 116 | 116 | wc.format = "%%" |
| 117 | if (wc.C & DidentRight) != 0 { | |
| 117 | if wc.C&DidentRight != 0 { | |
| 118 | 118 | wc.format += "-" |
| 119 | 119 | } |
| 120 | 120 | wc.format += "%ds" |