Go中的getpasswd功能? [英] getpasswd functionality in Go?

查看:38
本文介绍了Go中的getpasswd功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:

我想从 stdin 控制台获取密码条目 - 不回显用户键入的内容.Go 中是否有与 getpasswd 功能相媲美的功能?

I want to get a password entry from the stdin console - without echoing what the user types. Is there something comparable to getpasswd functionality in Go?

我尝试了什么:

我尝试使用 syscall.Read,但它会回显输入的内容.

I tried using syscall.Read, but it echoes what is typed.

推荐答案

你可以通过执行 stty -echo 来关闭 echo ,然后在阅读后执行 stty echo在密码中将其重新打开

you can do this by execing stty -echo to turn off echo and then stty echo after reading in the password to turn it back on

这篇关于Go中的getpasswd功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆