Closed larzconwell closed 10 years ago
I cannot reproduce your issue. This works for me:
func main() {
for {
l := liner.NewLiner()
s, err := l.Prompt("Prompt: ")
if err != nil {
fmt.Println("error", err)
l.Close()
os.Exit(1)
}
fmt.Println("got", s)
l.Close()
}
}
Don't forget to l.Close()
before you call NewLiner again.
Actually, try to call NewLiner only once; NewLiner leaks memory on go 1.0 (because there was no way to unregister a signal handler before Go 1.1).
That code doesn't work for me either. I get the same error as above.
What system are you on? I'm running Linux.
EDIT: but yeah I'll make it so only one NewLiner is allocated, but this is still an issue I think.
I can reproduce on Linux. Thanks for the bug report.
Each time you call NewLiner after the first time it swallows a character from input when you call Prompt.
Here's an example: https://gist.github.com/larzconwell/9624785
Actual output:
Expected output: