Merge pull request #22 from 178inaba/cmd_input

Fix tty.Open() position
pull/24/head
mattn 2017-04-17 23:28:38 +09:00 committed by GitHub
commit b6d4c40dd6
1 changed files with 5 additions and 6 deletions

View File

@ -66,12 +66,6 @@ var (
) )
func prompt() (string, string, error) { func prompt() (string, string, error) {
t, err := tty.Open()
if err != nil {
return "", "", err
}
defer t.Close()
fmt.Print("E-Mail: ") fmt.Print("E-Mail: ")
email, err := readUsername() email, err := readUsername()
if err != nil { if err != nil {
@ -81,6 +75,11 @@ func prompt() (string, string, error) {
fmt.Print("Password: ") fmt.Print("Password: ")
var password string var password string
if readPassword == nil { if readPassword == nil {
t, err := tty.Open()
if err != nil {
return "", "", err
}
defer t.Close()
password, err = t.ReadPassword() password, err = t.ReadPassword()
} else { } else {
password, err = readPassword() password, err = readPassword()