refactor examples
Vladimir Bauer
9 years ago
| 60 | 60 |
// create bar with appropriate decorators
|
| 61 | 61 |
bar := p.AddBar(size).
|
| 62 | 62 |
PrependName(name, 0, 0).
|
| 63 | |
PrependCounters(mpb.UnitBytes, 18, mpb.DwidthSync|mpb.DextraSpace).
|
|
63 |
PrependCounters("%3s / %3s", mpb.UnitBytes, 18, mpb.DwidthSync|mpb.DextraSpace).
|
| 64 | 64 |
AppendETA(5, mpb.DwidthSync)
|
| 65 | 65 |
|
| 66 | 66 |
// create proxy reader
|
| 37 | 37 |
p := mpb.New(nil).SetWidth(64)
|
| 38 | 38 |
|
| 39 | 39 |
bar := p.AddBar(size).
|
| 40 | |
PrependCounters(mpb.UnitBytes, 18, 0).
|
|
40 |
PrependCounters("%3s / %3s", mpb.UnitBytes, 18, 0).
|
| 41 | 41 |
AppendETA(3, 0)
|
| 42 | 42 |
|
| 43 | 43 |
// create proxy reader
|
| 11 | 11 |
func main() {
|
| 12 | 12 |
var wg sync.WaitGroup
|
| 13 | 13 |
p := mpb.New(nil)
|
|
14 |
wg.Add(3) // add wg delta
|
| 14 | 15 |
for i := 0; i < 3; i++ {
|
| 15 | |
wg.Add(1) // add wg delta
|
| 16 | 16 |
name := fmt.Sprintf("Bar#%d:", i)
|
| 17 | |
bar := p.AddBar(100).PrependName(name, len(name)).AppendPercentage()
|
|
17 |
bar := p.AddBar(100).
|
|
18 |
PrependName(name, len(name), 0).
|
|
19 |
AppendPercentage(5, 0)
|
| 18 | 20 |
go func() {
|
| 19 | 21 |
defer wg.Done()
|
| 20 | 22 |
// you can p.AddBar() here, but ordering will be non deterministic
|
| 22 | 22 |
|
| 23 | 23 |
// Add a bar. You're not limited to just one bar, add many if you need.
|
| 24 | 24 |
bar := p.AddBar(100).
|
| 25 | |
PrependName("Single Bar:", 0, mpb.DwidthSync).
|
|
25 |
PrependName("Single Bar:", 0, 0).
|
| 26 | 26 |
AppendPercentage(5, 0)
|
| 27 | 27 |
|
| 28 | 28 |
for i := 0; i < 100; i++ {
|