Last active
August 30, 2021 13:46
-
-
Save narukoshin/1a14ade4d0464189024adbecb9d88e2f to your computer and use it in GitHub Desktop.
no-echo input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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