Open v8oss opened 6 years ago
@v8oss can you post a full snippet/gist of the function? Your code shows a default prompt, but the panic seems to be a confirmation prompt.
I tried replicating the problem with both prompt and confirm prompts, seems to be working ok. Are you running it inside a go-routine?
@luizbranco I tried to run promptui/_examples/confirm/main.go, I can find this problem about 30% chance. Crtl+C or Ctrl+D
[shawn@se129 confirm]$ ./main ? Delete Resource? [y/N] █
panic: bytes.Buffer: truncation out of range
goroutine 1 [running]: bytes.(Buffer).Truncate(0xc4200b2070, 0x0) /usr/lib/golang/src/bytes/buffer.go:74 +0xc1 bytes.(Buffer).WriteTo(0xc4200b2070, 0x657700, 0xc4200da000, 0x68a4c8, 0x0, 0x0) /usr/lib/golang/src/bytes/buffer.go:228 +0x5b github.com/manifoldco/promptui/screenbuf.(ScreenBuf).Flush(0xc4200e0000, 0x0, 0x0) /home/users/shawn/go/src/github.com/manifoldco/promptui/screenbuf/screenbuf.go:115 +0x107 github.com/manifoldco/promptui.(Prompt).Run(0xc42005d2d0, 0xc420051f00, 0x564080, 0xc420010cb0, 0xc42000c500) /home/users/shawn/go/src/github.com/manifoldco/promptui/prompt.go:220 +0x9c9 main.main() /home/users/shawn/go/src/github.com/manifoldco/promptui/_examples/confirm/main.go:15 +0x111
Hi @luizbranco, This issue is related on go version.
go version go1.10 linux/amd64 (ubuntu 18.04) good go version go1.8.3 linux/amd64 (centos 7.4) bad go version go1.10.3 linux/amd64 (centos 7.4) good >> https://go-repo.io/
Thanks,
I'm getting random panics if I press ctrl-C instead of answering, it's a simple prompt.
I'm checking for
promptui.ErrInterrupt
but it happens before that insideRun
.trace