When using the ProxyWriter, it doesn't seem as though CurrentKibiByte is being displayed or updated correctly.
Using the following example:
package main
import (
"fmt"
"io"
"net/http"
"github.com/vbauerster/mpb/v8"
"github.com/vbauerster/mpb/v8/decor"
)
func main() {
url := "https://httpbin.org/drip?duration=10&numbytes=20&delay=0&code=200"
resp, err := http.Get(url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
panic(fmt.Sprintf("bad status code: %d", resp.StatusCode))
}
p := mpb.New(mpb.WithWidth(4))
bar := p.New(-1,
mpb.NopStyle(),
mpb.PrependDecorators(decor.CurrentKibiByte("% .2f")),
mpb.AppendDecorators(decor.Elapsed(decor.ET_STYLE_GO)),
)
pw := bar.ProxyWriter(io.Discard)
_, err = io.Copy(pw, resp.Body)
if err != nil {
panic(err)
}
}
The output is as follows:
Notice that it continues to show 0.00b
Interestingly (and without totally understanding the code base), I looked at proxywriter.go in function newProxyWriter and noticed lines 62-64:
pw := proxyWriter{wc, b}
if _, ok := w.(io.ReaderFrom); ok {
return proxyReaderFrom{pw}
}
return pw
If I remove that check so that the pw is returned, the bytes are displayed correctly.
For example:
When using the ProxyWriter, it doesn't seem as though
CurrentKibiByteis being displayed or updated correctly.Using the following example:
The output is as follows:
Notice that it continues to show
0.00bInterestingly (and without totally understanding the code base), I looked at
proxywriter.goin functionnewProxyWriterand noticed lines62-64:If I remove that check so that the
pwis returned, the bytes are displayed correctly.For example: