Replace echo input when entering a password

Viewed 25

I'm trying to enter a password replacing the echo of the standard input by '*' using Golang. The default behavior of func ReadPassword(fd int) ([]byte, error) of package golang.org/x/term is to remove all the echo. But I want to create a more user-friendly interface so users can know that they are writing something.

So far the best solution has been this one, which is pretty good, but when I delete a character from the input, the number of '*' does not decrease.

So I was wondering if there is any native way of replacing the echo of the standard input without losing the real input.

Thank you!

0 Answers
Related