You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey,
this is a nice little library :)
I am trying to implement my own io.Writer to output to. Eventually I want to output the progress bar to a logging area I have put together in a terminal UI using this library however as a test case I have put together this:
import "github.com/schollz/progressbar"
type tmpStruct struct {
}
func (t *tmpStruct) Write(p []byte) (n int, err error) {
fmt.Fprintf(os.Stdout, string(p[:]))
return len(p), nil
}
func demoLoadingBarCount(maximumInt int) {
var buf tmpStruct
if bufWriter, ok := interface{}(buf).(io.Writer); ok {
bar := progressbar.NewOptions(
maximumInt,
progressbar.OptionSetTheme(progressbar.Theme{Saucer: "#", SaucerPadding: "-", BarStart: ">", BarEnd: "<"}),
progressbar.OptionSetWidth(10),
progressbar.OptionSetWriter(bufWriter),
)
for i := 0; i < maximumInt; i++ {
bar.Add(1)
time.Sleep(10 * time.Millisecond)
}
}
}
The above seems to compile fine, but I don't see the progress bar on the terminal. Eventually I will change the os.Stdout to the writer of the terminal UI but for now I want to understand why the above isn't showing the terminal. Any help greatly appreciated.
Thanks
The text was updated successfully, but these errors were encountered:
FYI to anyone running into this later on. I experienced something similar. If you set a custom writer using progressbar.OptionSetWriter and set progressbar.OptionFullWidth, the progress bar is not visible. It doesn't look like this package is able to get the terminal width it needs to determine max string length if it's not using os.Stdout. Manually setting the width with progressbar.OptionSetWidth makes the progress bar visible again.
Hey,
this is a nice little library :)
I am trying to implement my own io.Writer to output to. Eventually I want to output the progress bar to a logging area I have put together in a terminal UI using this library however as a test case I have put together this:
The above seems to compile fine, but I don't see the progress bar on the terminal. Eventually I will change the os.Stdout to the writer of the terminal UI but for now I want to understand why the above isn't showing the terminal. Any help greatly appreciated.
Thanks
The text was updated successfully, but these errors were encountered: