Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

prompt.String() stops input after first space is read, not after newline #3

Open
jandre opened this issue Apr 20, 2015 · 0 comments · May be fixed by #4
Open

prompt.String() stops input after first space is read, not after newline #3

jandre opened this issue Apr 20, 2015 · 0 comments · May be fixed by #4

Comments

@jandre
Copy link

jandre commented Apr 20, 2015

Test code:

package main

import (
    "fmt"

    prompt "github.com/segmentio/go-prompt"
)

func main() {
    str := prompt.String("Enter some string")
    fmt.Println("Read:", str)
}

running it shows that it breaks at the first space, rather than at the newline:

vagrant@vagrant-ubuntu-trusty-64:/opt/secrets$ go run test.go
Enter some string: ljadjf lasdjflaksjflasdjfl asjfladjsfl
Read: ljadjf
vagrant@vagrant-ubuntu-trusty-64:/opt/secrets$ asdjflaksjflasdjfl asjfladjsfl
asdjflaksjflasdjfl: command not found

I think the expected behavior is that it should function like readline and terminate after a newline, not after a space is inputted.

jandre added a commit to jandre/go-prompt that referenced this issue Apr 20, 2015
itay-bardugo pushed a commit to itay-bardugo/go-prompt that referenced this issue Sep 14, 2018
use bufio.NewScanner() instead fmt.Scanln for spaces support
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant