File tree 1 file changed +9
-6
lines changed
test/testdata/govet_custom_formatter 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,15 @@ const (
10
10
escape = "\x1b "
11
11
reset = escape + "[0m"
12
12
green = escape + "[32m"
13
+
14
+ minValue = 0.0
15
+ maxValue = 1.0
13
16
)
14
17
15
18
// Bar is a progress bar.
16
19
type Bar float64
17
20
18
- var _ fmt.Formatter = Bar (1.0 )
21
+ var _ fmt.Formatter = Bar (maxValue )
19
22
20
23
// Format the progress bar as output
21
24
func (h Bar ) Format (state fmt.State , r rune ) {
@@ -25,16 +28,16 @@ func (h Bar) Format(state fmt.State, r rune) {
25
28
panic (fmt .Sprintf ("%v: unexpected format character" , float64 (h )))
26
29
}
27
30
28
- if h > 1.0 {
29
- h = 1.0
31
+ if h > maxValue {
32
+ h = maxValue
30
33
}
31
34
32
- if h < 0.0 {
33
- h = 0.0
35
+ if h < minValue {
36
+ h = minValue
34
37
}
35
38
36
39
if state .Flag ('-' ) {
37
- h = 1.0 - h
40
+ h = maxValue - h
38
41
}
39
42
40
43
width , ok := state .Width ()
You can’t perform that action at this time.
0 commit comments