[term] Use stdin file descriptor in example

44 views
Skip to first unread message

Tobias Klauser (Gerrit)

unread,
Mar 17, 2021, 11:32:34 AM3/17/21
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Ian Lance Taylor, Go Bot, golang-co...@googlegroups.com

Tobias Klauser submitted this change.

View Change

Approvals: Ian Lance Taylor: Looks good to me, approved; Run TryBots Tobias Klauser: Looks good to me, approved Go Bot: TryBots succeeded
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 <ia...@golang.org>
TryBot-Result: Go Bot <go...@golang.org>
Reviewed-by: Ian Lance Taylor <ia...@golang.org>
Reviewed-by: Tobias Klauser <tobias....@gmail.com>
---
M term.go
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.

To view, visit change 280232. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: term
Gerrit-Branch: master
Gerrit-Change-Id: Ie7915b1e0e1018fcb92b6ba006fe85a9aee439ad
Gerrit-Change-Number: 280232
Gerrit-PatchSet: 3
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Tobias Klauser <tobias....@gmail.com>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages