Skip to content
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

x/term: ReadKey() interface #13299

techtonik opened this Issue Nov 18, 2015 · 1 comment


None yet
2 participants
Copy link

techtonik commented Nov 18, 2015

Now that there is x/term (#13104) there should be some user stories.

The story here is that in LXC we have console client and server separated by websocket channel. Client uses os.Stdin to read the input from user. Server interprets what is being sent to it (passes it to pty?) Client most likely uses Read function from, for which os.Stdin.Read() returns nothing on Windows.

This interface on Linux is flawed in the first place, because I personally don't understand what it should return on read from os.Stdin if I hit arrow key. What cryptic code it returns/expects on Linux part is a separate mystery to me.

So perhaps there should be a better interface - synchronous ReadKey() and that will return keys in a sequence, and combinations of keys are also tracked.

And if we catch keys, it is better to returns values that are serializable in some cross-platform formats to avoid dependency on certain import and receive ability to switch packages who provide ReadKey() interface easily. I'd use strings like Ctrl-Q etc.

Hopefully that's clear. And I want to use Ctrl-Q in golang programs and Ctrl-V for my own purposes. And I also don't want Linux terminal to hang if I kill go process somewhere in the middle after go already switched terminal to some non-friendly state for its own purpose.


This comment has been minimized.

Copy link

techtonik commented Nov 18, 2015


@rsc rsc added this to the Unreleased milestone Dec 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.