@@ -106,17 +106,15 @@ func (w *wizard) readString() string {
106106// readDefaultString reads a single line from stdin, trimming if from spaces. If
107107// an empty line is entered, the default value is returned.
108108func (w * wizard ) readDefaultString (def string ) string {
109- for {
110- fmt .Printf ("> " )
111- text , err := w .in .ReadString ('\n' )
112- if err != nil {
113- log .Crit ("Failed to read user input" , "err" , err )
114- }
115- if text = strings .TrimSpace (text ); text != "" {
116- return text
117- }
118- return def
109+ fmt .Printf ("> " )
110+ text , err := w .in .ReadString ('\n' )
111+ if err != nil {
112+ log .Crit ("Failed to read user input" , "err" , err )
119113 }
114+ if text = strings .TrimSpace (text ); text != "" {
115+ return text
116+ }
117+ return def
120118}
121119
122120// readInt reads a single line from stdin, trimming if from spaces, enforcing it
@@ -207,15 +205,13 @@ func (w *wizard) readDefaultFloat(def float64) float64 {
207205// readPassword reads a single line from stdin, trimming it from the trailing new
208206// line and returns it. The input will not be echoed.
209207func (w * wizard ) readPassword () string {
210- for {
211- fmt .Printf ("> " )
212- text , err := terminal .ReadPassword (int (syscall .Stdin ))
213- if err != nil {
214- log .Crit ("Failed to read password" , "err" , err )
215- }
216- fmt .Println ()
217- return string (text )
208+ fmt .Printf ("> " )
209+ text , err := terminal .ReadPassword (int (syscall .Stdin ))
210+ if err != nil {
211+ log .Crit ("Failed to read password" , "err" , err )
218212 }
213+ fmt .Println ()
214+ return string (text )
219215}
220216
221217// readAddress reads a single line from stdin, trimming if from spaces and converts
0 commit comments