-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
term: add examples for ReadPassword #4
base: master
Are you sure you want to change the base?
Conversation
This PR (HEAD: 1712572) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/term/+/324829 to see it. Tip: You can toggle comments from me using the |
1712572
to
b2824fc
Compare
This PR (HEAD: b2824fc) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/term/+/324829 to see it. Tip: You can toggle comments from me using the |
@alexbrainman said in golang/go#46164 (comment) that he would rather use the Windows API for opening |
Message from Richard Ulmer: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/324829. |
Message from TurkDevOps DevTurks-Team: Patch Set 2: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/324829. |
Message from Alex Brainman: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/324829. |
These examples demonstrate how to use ReadPassword for interactive password input from the terminal. They highlight how to use the function, even if standard input is not a terminal (e.g. when it is a pipe).
b2824fc
to
136cee7
Compare
This PR (HEAD: 136cee7) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/term/+/324829 to see it. Tip: You can toggle comments from me using the |
Message from Kadir Selçuk : Patch Set 2: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/324829. |
Message from Alex Brainman: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/324829. |
Thank you for contributing this example! Unfortunately when I try to use your technique in my program I get:
|
@acnodal-tc What operating system are you using and which of the three examples did you try? |
I'm on Debian 11:
I integrated the code from ExampleReadPassword_unix() into my program, and it works great when I run it locally but if I run it using ssh it crashes:
|
@acnodal-tc The |
Ah, thank you. Perhaps this comment isn't accurate, then: "If standard input is not bound to the terminal, a password can still be read from it." |
The "it" in "a password can still be read from it" refers to the terminal, not the standard input. To read from standard input, you don't need the |
Gotcha. Thank you! |
…ally add to the History (golang#4) * Add AutoHistory(false) option (default remains true) to not automatically add to the History and let the caller of ReadLine() decide, for instance to only add validated commands
These examples demonstrate how to use ReadPassword for interactive password input from the terminal. They highlight how to use the function, even if standard input is not a terminal (e.g. when it is a pipe). The example for Windows is especially interesting, because there seems to be a bug where CONIN$ cannot be used unless opened with the write flag.
This contribution was suggested to me at golang/go#46164.