diff --git a/example/main.go b/example/main.go index cc1a32a..5b5ed3b 100644 --- a/example/main.go +++ b/example/main.go @@ -47,15 +47,13 @@ var completer = readline.NewPrefixCompleter( ) func main() { - cfg := &readline.Config{ + l, err := readline.NewEx(&readline.Config{ Prompt: "\033[31m»\033[0m ", HistoryFile: "/tmp/readline.tmp", AutoComplete: completer, InterruptPrompt: "\nInterrupt, Press Ctrl+D to exit", EOFPrompt: "exit", - } - - l, err := readline.NewEx(cfg) + }) if err != nil { panic(err) } diff --git a/operation.go b/operation.go index 8592de1..4ea03da 100644 --- a/operation.go +++ b/operation.go @@ -315,7 +315,9 @@ func (o *Operation) GenPasswordConfig() *Config { } func (o *Operation) PasswordWithConfig(cfg *Config) ([]byte, error) { - o.opPassword.EnterPasswordMode(cfg) + if err := o.opPassword.EnterPasswordMode(cfg); err != nil { + return nil, err + } defer o.opPassword.ExitPasswordMode() return o.Slice() }