envoid/internal/prompt/password.go
Sagi Dayan d5d1eecb89
Some checks failed
Codespell / Check for spelling errors (push) Failing after 1m26s
Initial commit
Signed-off-by: Sagi Dayan <sagidayan@gmail.com>
2024-12-12 20:18:00 +02:00

23 lines
295 B
Go

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