From de623e64d2a6562fa463152da80477d4aa07fca0 Mon Sep 17 00:00:00 2001 From: makeworld <25111343+makeworld-the-better-one@users.noreply.github.com> Date: Sat, 26 Dec 2020 19:06:28 +0000 Subject: [PATCH] term: use stdin file descriptor in comment Using a `fd` of `0` on Windows will crash with `panic: The handle is invalid.` By getting the file descriptor from `os.Stdin`, this can be avoided. Change-Id: Ie7915b1e0e1018fcb92b6ba006fe85a9aee439ad GitHub-Last-Rev: 4e56574120c1a5351f180f3290bc9407f3d6976f GitHub-Pull-Request: golang/term#3 Reviewed-on: https://go-review.googlesource.com/c/term/+/280232 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Reviewed-by: Tobias Klauser --- term.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/term.go b/term.go index 2a4ccf8..1f6a38f 100644 --- a/term.go +++ b/term.go @@ -7,11 +7,11 @@ // // Putting a terminal into raw mode is the most common requirement: // -// oldState, err := term.MakeRaw(0) +// oldState, err := term.MakeRaw(int(os.Stdin.Fd())) // if err != nil { // panic(err) // } -// defer term.Restore(0, oldState) +// defer term.Restore(int(os.Stdin.Fd()), oldState) package term // State contains the state of a terminal.