diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-08-04 23:00:22 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-08-04 23:00:22 +0800 |
commit | 455fcc830972f453456195c4118233fec030ca4d (patch) | |
tree | b52e9ae9f488de8d134c273254867613dba14eea | |
parent | 0cc9b8791e63473c1c06609010ef51c587c82bcb (diff) | |
download | go-tangerine-455fcc830972f453456195c4118233fec030ca4d.tar go-tangerine-455fcc830972f453456195c4118233fec030ca4d.tar.gz go-tangerine-455fcc830972f453456195c4118233fec030ca4d.tar.bz2 go-tangerine-455fcc830972f453456195c4118233fec030ca4d.tar.lz go-tangerine-455fcc830972f453456195c4118233fec030ca4d.tar.xz go-tangerine-455fcc830972f453456195c4118233fec030ca4d.tar.zst go-tangerine-455fcc830972f453456195c4118233fec030ca4d.zip |
cmd/puppeth: remove wrapping loop in single reads
-rw-r--r-- | cmd/puppeth/wizard.go | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/cmd/puppeth/wizard.go b/cmd/puppeth/wizard.go index 51e64688e..288b67508 100644 --- a/cmd/puppeth/wizard.go +++ b/cmd/puppeth/wizard.go @@ -106,17 +106,15 @@ func (w *wizard) readString() string { // readDefaultString reads a single line from stdin, trimming if from spaces. If // an empty line is entered, the default value is returned. func (w *wizard) readDefaultString(def string) string { - for { - fmt.Printf("> ") - text, err := w.in.ReadString('\n') - if err != nil { - log.Crit("Failed to read user input", "err", err) - } - if text = strings.TrimSpace(text); text != "" { - return text - } - return def + fmt.Printf("> ") + text, err := w.in.ReadString('\n') + if err != nil { + log.Crit("Failed to read user input", "err", err) } + if text = strings.TrimSpace(text); text != "" { + return text + } + return def } // readInt reads a single line from stdin, trimming if from spaces, enforcing it @@ -207,15 +205,13 @@ func (w *wizard) readDefaultFloat(def float64) float64 { // readPassword reads a single line from stdin, trimming it from the trailing new // line and returns it. The input will not be echoed. func (w *wizard) readPassword() string { - for { - fmt.Printf("> ") - text, err := terminal.ReadPassword(int(syscall.Stdin)) - if err != nil { - log.Crit("Failed to read password", "err", err) - } - fmt.Println() - return string(text) + fmt.Printf("> ") + text, err := terminal.ReadPassword(int(syscall.Stdin)) + if err != nil { + log.Crit("Failed to read password", "err", err) } + fmt.Println() + return string(text) } // readAddress reads a single line from stdin, trimming if from spaces and converts |