mcchunkie/pass_reader.go

20 lines
296 B
Go
Raw Normal View History

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