From 07e1b5f346ab584271b75b7493dbcbac93b0994c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 9 Feb 2026 10:10:29 +0100 Subject: [PATCH] windows: GetHandleInfo: combine checks into a single switch Signed-off-by: Sebastiaan van Stijn --- windows/console.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/windows/console.go b/windows/console.go index 21e57bd..439a744 100644 --- a/windows/console.go +++ b/windows/console.go @@ -16,16 +16,12 @@ func GetHandleInfo(in interface{}) (uintptr, bool) { return t.Fd(), true case *ansiWriter: return t.Fd(), true + case *os.File: + fd := t.Fd() + return fd, isConsole(fd) + default: + return 0, false } - - var inFd uintptr - var isTerminal bool - - if file, ok := in.(*os.File); ok { - inFd = file.Fd() - isTerminal = isConsole(inFd) - } - return inFd, isTerminal } // IsConsole returns true if the given file descriptor is a Windows Console.