Documentation ¶
Overview ¶
This package provides a robust way to read password from the terminal.
Features:
- Read password from the terminal.
- Mute the terminal while inputting the password.
- If interrupted while inputting the password, the terminal will be turned back to normal.
- If the input is not from the terminal, it will read from the Env.In.
Dependencies:
- github.com/tappoy/env (Env.In)
- golang.org/x/crypto/ssh/terminal
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // The input process is interrupted. ErrInterrupted = errors.New("ErrInterrupted") )
View Source
var (
// The dummy password to generate ErrInterrupted.
Interrupt = "Interrupt"
)
Functions ¶
This section is empty.
Types ¶
type PasswordInput ¶ added in v1.1.0
type PasswordInput interface { // InputPassword reads a password from the terminal. // If DummyPasswordInput is used, it will return the dummy password. // Errors: // - ErrInterrupted InputPassword() (string, error) }
func NewDummyPasswordInput ¶ added in v1.1.0
func NewDummyPasswordInput(dummyPassword string) PasswordInput
Create a dummy password reader for testing or some other purposes. It will return the dummy password when calling `Inputssword()`.
If dummyPassword is "Interrupt" or pwinput.Interrupt, it will return ErrInterrupted when calling `InputPassword()`
func NewPasswordInput ¶ added in v1.1.0
func NewPasswordInput() PasswordInput
Create a new password reader.
Click to show internal directories.
Click to hide internal directories.