Skip to content

Commit cc8b910

Browse files
committed
Fix test failure from gomnd
1 parent e76db1a commit cc8b910

File tree

1 file changed

+9
-6
lines changed
  • test/testdata/govet_custom_formatter

1 file changed

+9
-6
lines changed

test/testdata/govet_custom_formatter/main.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff 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.
1619
type Bar float64
1720

18-
var _ fmt.Formatter = Bar(1.0)
21+
var _ fmt.Formatter = Bar(maxValue)
1922

2023
// Format the progress bar as output
2124
func (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()

0 commit comments

Comments
 (0)