Last active
January 26, 2025 22:30
-
-
Save sheepla/bfcd4e92e5e7f10ce0265acf9056b13e to your computer and use it in GitHub Desktop.
Progress bar implementation in Go with github.com/cheggaaa/pb/v3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"progressbar_example/progress" | |
"time" | |
) | |
func main() { | |
count := 10000 | |
bar := progress.NewProgressBar(int64(count)) | |
bar. | |
Start() | |
defer bar.Finish() | |
for i := 0; i < count; i++ { | |
bar.Increment() | |
time.Sleep(1 * time.Millisecond) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package progress | |
import ( | |
"time" | |
pb "github.com/cheggaaa/pb/v3" | |
) | |
func NewProgressBar(count int64) *pb.ProgressBar { | |
return pb.New64(count). | |
SetTemplate( | |
` Progress: {{ bar . "[" "▉" (cycle . "⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏") "." "]"}} {{ percent . }} `, | |
). | |
SetRefreshRate(100 * time.Millisecond) | |
} |
Author
sheepla
commented
Jan 26, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment