File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed
test/testdata/govet_custom_formatter Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ linters:
7474 - gofmt
7575 - goimports
7676 - golint
77- # - gomnd TODO: enable it with release > v1.23.0
77+ - gomnd
7878 - goprintffuncname
7979 - gosec
8080 - gosimple
Original file line number Diff line number Diff line change @@ -1015,7 +1015,7 @@ linters:
10151015 - gofmt
10161016 - goimports
10171017 - golint
1018- # - gomnd TODO: enable it with release > v 1 . 23 . 0
1018+ - gomnd
10191019 - goprintffuncname
10201020 - gosec
10211021 - gosimple
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