From f9bf865cb0d489dfebe9abc98849070791e9ffa3 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 7 Mar 2018 16:05:27 +0100 Subject: [PATCH] ssh/terminal: simplify defer Directly use unix.IoctlSetTermios and windows.SetConsoleMode instead of wrapping them with a closure. Change-Id: I6309253fbb6e59e029424273b48aaa608873ea17 Reviewed-on: https://go-review.googlesource.com/99455 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- util.go | 4 +--- util_windows.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/util.go b/util.go index 02dad48..731c89a 100644 --- a/util.go +++ b/util.go @@ -108,9 +108,7 @@ func ReadPassword(fd int) ([]byte, error) { return nil, err } - defer func() { - unix.IoctlSetTermios(fd, ioctlWriteTermios, termios) - }() + defer unix.IoctlSetTermios(fd, ioctlWriteTermios, termios) return readPasswordLine(passwordReader(fd)) } diff --git a/util_windows.go b/util_windows.go index 4933ac3..8618955 100644 --- a/util_windows.go +++ b/util_windows.go @@ -89,9 +89,7 @@ func ReadPassword(fd int) ([]byte, error) { return nil, err } - defer func() { - windows.SetConsoleMode(windows.Handle(fd), old) - }() + defer windows.SetConsoleMode(windows.Handle(fd), old) var h windows.Handle p, _ := windows.GetCurrentProcess()