mcchunkie/pass_reader.go

20 lines
323 B
Go
Raw Normal View History

package main
import (
"os"
"golang.org/x/crypto/ssh/terminal"
)
2020-05-13 17:36:26 -06:00
//noinspection GoUnresolvedReference
func prompt(p string) (string, error) {
oldState, err := terminal.MakeRaw(0)
if err != nil {
panic(err)
}
defer terminal.Restore(0, oldState)
t := terminal.NewTerminal(os.Stdin, p)
return t.ReadPassword(p)
}