From 7a2277bc18e8f37af7d72d257c124c20a459baf5 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 18 Jun 2025 17:03:53 +0700 Subject: [PATCH] refactor: move client info handling to desktop-specific files Move client information related functions from client_info_*.go to desktop_*.go files to better organize platform-specific code and separate desktop functionality from shared code. No functional changes. --- client_info_darwin.go | 4 ---- client_info_others.go | 6 ------ client_info_windows.go | 18 ------------------ desktop_darwin.go | 3 +++ desktop_others.go | 3 +++ desktop_windows.go | 15 +++++++++++++++ 6 files changed, 21 insertions(+), 28 deletions(-) delete mode 100644 client_info_darwin.go delete mode 100644 client_info_others.go delete mode 100644 client_info_windows.go diff --git a/client_info_darwin.go b/client_info_darwin.go deleted file mode 100644 index 4c3d10b..0000000 --- a/client_info_darwin.go +++ /dev/null @@ -1,4 +0,0 @@ -package ctrld - -// SelfDiscover reports whether ctrld should only do self discover. -func SelfDiscover() bool { return true } diff --git a/client_info_others.go b/client_info_others.go deleted file mode 100644 index d728913..0000000 --- a/client_info_others.go +++ /dev/null @@ -1,6 +0,0 @@ -//go:build !windows && !darwin - -package ctrld - -// SelfDiscover reports whether ctrld should only do self discover. -func SelfDiscover() bool { return false } diff --git a/client_info_windows.go b/client_info_windows.go deleted file mode 100644 index f20bca7..0000000 --- a/client_info_windows.go +++ /dev/null @@ -1,18 +0,0 @@ -package ctrld - -import ( - "golang.org/x/sys/windows" -) - -// isWindowsWorkStation reports whether ctrld was run on a Windows workstation machine. -func isWindowsWorkStation() bool { - // From https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa - const VER_NT_WORKSTATION = 0x0000001 - osvi := windows.RtlGetVersion() - return osvi.ProductType == VER_NT_WORKSTATION -} - -// SelfDiscover reports whether ctrld should only do self discover. -func SelfDiscover() bool { - return isWindowsWorkStation() -} diff --git a/desktop_darwin.go b/desktop_darwin.go index 039c0fa..7ba8b6b 100644 --- a/desktop_darwin.go +++ b/desktop_darwin.go @@ -5,3 +5,6 @@ package ctrld func IsDesktopPlatform() bool { return true } + +// SelfDiscover reports whether ctrld should only do self discover. +func SelfDiscover() bool { return true } diff --git a/desktop_others.go b/desktop_others.go index de486e7..6d6a9a3 100644 --- a/desktop_others.go +++ b/desktop_others.go @@ -7,3 +7,6 @@ package ctrld func IsDesktopPlatform() bool { return false } + +// SelfDiscover reports whether ctrld should only do self discover. +func SelfDiscover() bool { return false } diff --git a/desktop_windows.go b/desktop_windows.go index 4e9526b..186a5ff 100644 --- a/desktop_windows.go +++ b/desktop_windows.go @@ -1,7 +1,22 @@ package ctrld +import "golang.org/x/sys/windows" + // IsDesktopPlatform indicates if ctrld is running on a desktop platform, // currently defined as macOS or Windows workstation. func IsDesktopPlatform() bool { return isWindowsWorkStation() } + +// SelfDiscover reports whether ctrld should only do self discover. +func SelfDiscover() bool { + return isWindowsWorkStation() +} + +// isWindowsWorkStation reports whether ctrld was run on a Windows workstation machine. +func isWindowsWorkStation() bool { + // From https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa + const VER_NT_WORKSTATION = 0x0000001 + osvi := windows.RtlGetVersion() + return osvi.ProductType == VER_NT_WORKSTATION +}