Repository navigation
fix: enable Windows compilation with platform-specific build tags - #2108
Merged
Seanstoppable merged 4 commits intoJul 23, 2026
Merged
Seanstoppable merged 4 commits into
Seanstoppable merged 4 commits into
Conversation
- Split cmdrunner PTY/SIGWINCH code into pty_unix.go (build tag !windows) and pty_windows.go stub that returns an error (fixes wtfutil#1574) - Extract firewall Linux-specific syscall.WaitStatus usage into firewall_unix.go (!windows) with a Windows stub - Add battery_windows.go and source_windows.go for the power module using WMI via PowerShell (instead of macOS-only pmset) - Fix mercurial hg_repo.go: use path/filepath instead of path for cross-platform path handling
Replace runtime.GOOS dispatch with build-tagged files so each platform has a proper FirewallState()/FirewallStealthState() implementation. Eliminates stub functions for cross-platform compilation.
…ows) Each platform now has its own dedicated file with a direct FirewallState()/FirewallStealthState() implementation. Added firewall_other.go as a no-op fallback for unsupported platforms.
The statusLabel helper is only used by the darwin firewall implementation. Moving it there eliminates the shared firewall.go file entirely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes wtfutil compile and run on Windows by splitting platform-specific code into build-tagged files.
Fixes #1574
Changes
modules/cmdrunner/— PTY support splitpty_unix.go(!windowsbuild tag)pty_windows.gothat returns a clear error when PTY mode is requested (sincecreack/ptyandsyscall.SIGWINCHare Unix-only)modules/security/— Firewall build fixfirewallStateLinux()andcheckFirewalld()(which usesyscall.WaitStatus) intofirewall_unix.go(!windowsbuild tag)firewall_windows.gostub (the Windows firewall implementation in the main file already works)modules/power/— Windows battery supportbattery_windows.gousing WMI (Win32_Battery) via PowerShellsource_windows.gofor power source detectionbattery.go,source.go) to exclude Windows with!linux && !freebsd && !windowsmodules/mercurial/— Cross-platform path handlingpathwithpath/filepathinhg_repo.gofor correct Windows path separatorsTesting
GOOS=windows go build ./...— compiles cleanlyGOOS=linux go build ./...— compiles cleanlyGOOS=darwin go build ./...— compiles cleanly