Fix tty.Open() position

pull/22/head
178inaba 2017-04-17 22:39:57 +09:00
parent a0232ea6ef
commit d6ee0499f5
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()