progressbar icon indicating copy to clipboard operation
progressbar copied to clipboard

I think the variable about time should not be set to time.Now()

Open chengxilo opened this issue 5 months ago • 0 comments

I realized that we have this method https://github.com/schollz/progressbar/blob/03fc4e907750adc6f00a004986a63c80616923b8/progressbar.go#L361-L368 it was called by NewOption64 https://github.com/schollz/progressbar/blob/03fc4e907750adc6f00a004986a63c80616923b8/progressbar.go#L319-L334 So even we didn't render it, the lastShown time was set to time.Now() which is not so good for futher development. I think this variable shouldn't be set when the progress was render instead of called when the progress bar was just initialized.

We can use IsZero() to check whether the time is default value. And in my opinion, this change will make it possible for us to check whether the bar has been rendered before. If we could do that, we can add some goroutine for rendering the progress bar. Such as fix https://github.com/schollz/progressbar/issues/141 , if we can check whether the progress bar start rendering, we can start a goroutine for it and re-render the progress bar according to the time interval.

var n time.Time
fmt.Println(n.IsZero()) // output: true

And I think these arguments apply equally to lastShown and counterTime

I would like to ask your opinion on whether it needs to be changed and if it is ok, I'd like to pr for it.

chengxilo avatar Aug 29 '24 14:08 chengxilo