Skip to content

Commit bf2eea3

Browse files
committed
cli/command/container: hijackedIOStreamer.setupInput: use sync.OnceFunc
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 97e060e commit bf2eea3

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

cli/command/container/hijack.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,9 @@ func (h *hijackedIOStreamer) setupInput() (restore func(), err error) {
8484

8585
// Use sync.Once so we may call restore multiple times but ensure we
8686
// only restore the terminal once.
87-
var restoreOnce sync.Once
88-
restore = func() {
89-
restoreOnce.Do(func() {
90-
_ = restoreTerminal(h.streams, h.inputStream)
91-
})
92-
}
87+
restore = sync.OnceFunc(func() {
88+
_ = restoreTerminal(h.streams, h.inputStream)
89+
})
9390

9491
// Wrap the input to detect detach escape sequence.
9592
// Use default escape keys if an invalid sequence is given.

0 commit comments

Comments
 (0)