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
Simplify checkIfTerminal for Windows #1088
Conversation
88ede6e
to
dda7696
Compare
dda7696
to
4512a9a
Compare
4512a9a
to
2c3a578
Compare
Instead of relying on EnableVirtualTerminalProcessing from github.com/konsorten/go-windows-terminal-sequences which just calls GetConsoleMode, sets ENABLE_VIRTUAL_TERMINAL_PROCESSING and calls SetConsoleMode with the new modified mode, implement it directly inside checkIfTerminal. This also avoids the duplicate call to GetConsoleMode.
Rebased on latest master. Would be nice to get this merged in order to get rid of an additional dependency (which is unused on every platform but Windows). Is there anything else needed from my side? /cc @dgsb |
nice! Was recently working on something similar (didn't open a PR for that one yet; thanks for reminding me 😂 https://github.com/moby/term/compare/master...thaJeztah:deprecate_isconsole?expand=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@dgsb ptal |
hello we are indeed getting rid of a dependency but we get another instead which seems a way bigger package. What is the advantage of that ? |
I agree the dependency itself is bigger but the Go linker will strip away any unused symbols, so in terms of binary size we should only pay for functionality we actually use. |
|
Ok, makes sense |
Simplify checkIfTerminal for Windows
Instead of relying on
EnableVirtualTerminalProcessing
fromgithub.com/konsorten/go-windows-terminal-sequences
which just callsGetConsoleMode
, setsENABLE_VIRTUAL_TERMINAL_PROCESSING
and callsSetConsoleMode
with the new modified mode, implement it directly insidecheckIfTerminal
. This also avoids the duplicate call toGetConsoleMode
and gets rid of an external dependency.