Codebase list golang-github-vbauerster-mpb / 0f09467
remove unnecessary width block Vladimir Bauer 6 years ago
1 changed file(s) with 3 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
33 "fmt"
44 "io"
55 "strconv"
6 "strings"
76
87 "github.com/vbauerster/mpb/v4/internal"
98 )
2625 }
2726 }
2827
29 var b strings.Builder
30 b.WriteString(strconv.FormatFloat(float64(s), 'f', prec, 64))
28 io.WriteString(st, strconv.FormatFloat(float64(s), 'f', prec, 64))
3129
3230 if st.Flag(' ') {
33 b.WriteString(" ")
31 io.WriteString(st, " ")
3432 }
35 b.WriteString("%")
36
37 if w, ok := st.Width(); ok {
38 if l := b.Len(); l < w {
39 pad := strings.Repeat(" ", w-l)
40 if st.Flag('-') {
41 b.WriteString(pad)
42 } else {
43 tmp := b.String()
44 b.Reset()
45 b.WriteString(pad)
46 b.WriteString(tmp)
47 }
48 }
49 }
50
51 io.WriteString(st, b.String())
33 io.WriteString(st, "%")
5234 }
5335
5436 // Percentage returns percentage decorator. It's a wrapper of NewPercentage.