File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
test/testdata/govet_custom_formatter Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,15 @@ const (
1010 escape = "\x1b "
1111 reset = escape + "[0m"
1212 green = escape + "[32m"
13+
14+ minValue = 0.0
15+ maxValue = 1.0
1316)
1417
1518// Bar is a progress bar.
1619type Bar float64
1720
18- var _ fmt.Formatter = Bar (1.0 )
21+ var _ fmt.Formatter = Bar (maxValue )
1922
2023// Format the progress bar as output
2124func (h Bar ) Format (state fmt.State , r rune ) {
@@ -25,16 +28,16 @@ func (h Bar) Format(state fmt.State, r rune) {
2528 panic (fmt .Sprintf ("%v: unexpected format character" , float64 (h )))
2629 }
2730
28- if h > 1.0 {
29- h = 1.0
31+ if h > maxValue {
32+ h = maxValue
3033 }
3134
32- if h < 0.0 {
33- h = 0.0
35+ if h < minValue {
36+ h = minValue
3437 }
3538
3639 if state .Flag ('-' ) {
37- h = 1.0 - h
40+ h = maxValue - h
3841 }
3942
4043 width , ok := state .Width ()
You can’t perform that action at this time.
0 commit comments