Skip to content

Instantly share code, notes, and snippets.

@narukoshin
Last active August 30, 2021 13:46
Show Gist options
  • Save narukoshin/1a14ade4d0464189024adbecb9d88e2f to your computer and use it in GitHub Desktop.
Save narukoshin/1a14ade4d0464189024adbecb9d88e2f to your computer and use it in GitHub Desktop.
no-echo input
package main
import (
"os"
"log"
// importing the term pacakge
"golang.org/x/term"
)
func main(){
// getting the fd
fd := int(os.Stdin.Fd())
// reading the password with no-echo
password, err := term.ReadPassword(fd)
// handling errors
if err != nil {
log.Fatal(err
}
// our sweet password
_ = password
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment