Codebase list golang-github-vbauerster-mpb / db7f3de
use percentage func Vladimir Bauer 9 years ago
1 changed file(s) with 2 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
7272
7373 func (b *Bar) AppendPercentage() *Bar {
7474 b.AppendFunc(func(s *Statistics) string {
75 completed := int(100 * float64(s.Current) / float64(s.Total))
75 completed := percentage(s.Total, s.Current, 100)
7676 return fmt.Sprintf("%3d %%", completed)
7777 })
7878 return b
8181 func (b *Bar) PrependPercentage(padding int) *Bar {
8282 layout := "%" + strconv.Itoa(padding) + "d %%"
8383 b.PrependFunc(func(s *Statistics) string {
84 completed := int(100 * float64(s.Current) / float64(s.Total))
84 completed := percentage(s.Total, s.Current, 100)
8585 return fmt.Sprintf(layout, completed)
8686 })
8787 return b