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 <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/ssh/terminal/util.go b/ssh/terminal/util.go
index 02dad48..731c89a 100644
--- a/ssh/terminal/util.go
+++ b/ssh/terminal/util.go
@@ -108,9 +108,7 @@
return nil, err
}
- defer func() {
- unix.IoctlSetTermios(fd, ioctlWriteTermios, termios)
- }()
+ defer unix.IoctlSetTermios(fd, ioctlWriteTermios, termios)
return readPasswordLine(passwordReader(fd))
}
diff --git a/ssh/terminal/util_windows.go b/ssh/terminal/util_windows.go
index 4933ac3..8618955 100644
--- a/ssh/terminal/util_windows.go
+++ b/ssh/terminal/util_windows.go
@@ -89,9 +89,7 @@
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()