import "github.com/schollz/progressbar/v3"
func main() {
pb := progressbar.NewOptions(
-1,
progressbar.OptionSetMaxDetailRow(1),
)
pb.ChangeMax(-1)
// this fails with
if err = pb.RenderBlank(); err != nil {
return err
}
}
It fails with the message:
panic: runtime error: index out of range [-1]
goroutine 1 [running]:
github.com/schollz/progressbar/v3.(*ProgressBar).render(0x1400011e508)
/Users/mega/.asdf/installs/golang/1.22.4/packages/pkg/mod/github.com/schollz/progressbar/v3@v3.17.0/progressbar.go:904 +0x4ac
github.com/schollz/progressbar/v3.(*ProgressBar).RenderBlank(0x1400011e508?)
/Users/mega/.asdf/installs/golang/1.22.4/packages/pkg/mod/github.com/schollz/progressbar/v3@v3.17.0/progressbar.go:597 +0xec
(rest omitted)
This is due to the call to ChangeMax(-1) calling lengthKnown(-1) instead of lengthUnknown().
Minimum example:
It fails with the message:
This is due to the call to
ChangeMax(-1)
callinglengthKnown(-1)
instead oflengthUnknown()
.