28 lines
303 B
Go
28 lines
303 B
Go
package prompt
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"syscall"
|
|
|
|
"golang.org/x/term"
|
|
)
|
|
|
|
func PasswordPrompt(label string) string {
|
|
var str string
|
|
|
|
for {
|
|
fmt.Fprint(os.Stderr, label+" ")
|
|
|
|
b, _ := term.ReadPassword(syscall.Stdin)
|
|
|
|
str = string(b)
|
|
if str != "" {
|
|
break
|
|
}
|
|
}
|
|
|
|
fmt.Println()
|
|
|
|
return str
|
|
}
|