go-libs / progress

Making a Progress for Reader/Writer read/write bytes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Progress.Current vs BytesWritten

pieterclaerhout opened this issue · comments

In the way I'm using the progress class in my app, I require to get the number of bytes that were written since the last time it calls the HandlerFunction. I'm tracking the upload of several files at once, and then the Current is a bit annoying to work with.

It would be handy if you could add next to Current the variable "BytesWritten". The calculate function would then look like:

func (p *Progress) calculate(n int64) {
    p.Current += n
    p.BytesWritten = n
    p.Expected = p.Total - p.Current
    if !p.IgnoreTotal && p.Expected < 0 {
        p.Current = p.Total
        p.Expected = 0
        p.Finished = true
    }
}