From 1d0f034c46d5bf73629b6480f8dbf4ec24e16375 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sat, 5 Apr 2025 14:41:08 -0700 Subject: Use int instead of float --- cmd/progress-bar/progress-bar.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/progress-bar/progress-bar.go b/cmd/progress-bar/progress-bar.go index 25e6216..19050c8 100644 --- a/cmd/progress-bar/progress-bar.go +++ b/cmd/progress-bar/progress-bar.go @@ -21,13 +21,12 @@ func run() error { return errors.New("usage error") } maxStr := args[0] - maxInt, err := strconv.Atoi(maxStr) + maxVal, err := strconv.Atoi(maxStr) if err != nil { return fmt.Errorf("max: %s", err) } - maxFloat := float64(maxInt) cmd := args[1:] - bar := new(progress.Bar) + bar := progress.New(maxVal) for i := 0; ; i++ { outputBytes, err := exec.Command(cmd[0], cmd[1:]...).Output() if err != nil { @@ -39,7 +38,7 @@ func run() error { fmt.Println(err) continue } - bar.Set(float64(output) / maxFloat) + bar.Set(output) bar.Print() time.Sleep(*n) } -- cgit v1.3.1