progressbar
progressbar copied to clipboard
ChangeMax not working
I start my progress bar as indeterminate for the first query that retrieves the count.
Then I set the count as the new max, my log line does show the correct number.
The progress bar never changes from indeterminate to an actual progress bar.
Here is my setup.
bar := progressbar.NewOptions(
-1,
progressbar.OptionSetDescription("Fetching messages from API"),
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionFullWidth(),
progressbar.OptionEnableColorCodes(true),
progressbar.OptionSetPredictTime(true),
progressbar.OptionShowCount(),
progressbar.OptionShowIts(),
progressbar.OptionShowElapsedTimeOnFinish(),
progressbar.OptionSetItsString("Msgs"),
progressbar.OptionSpinnerType(14),
progressbar.OptionSetRenderBlankState(true),
)
// This is just the initial query
folderMessages := f.getMessages(client, log.Named("Messages"), queryLimit)
msgCount := *folderMessages.GetOdataCount()
log.With(zap.Int64("Count", msgCount)).Info("Message Count")
bar.ChangeMax64(msgCount)
// Proceeds to the processing loop
And inside my loop.
if err := bar.Add(1); err != nil {
log.With(zap.Error(err)).Error("Failed to increment progress bar!")
}