Add FreeBSD/Unix support to sysutil package #231
Merged
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.
This PR adds support for FreeBSD and other Unix-like systems (OpenBSD, NetBSD, DragonFly BSD) to the
sysutilpackage, fixing build failures on these platforms.Problem
The
goutillibrary fails to build on FreeBSD and other Unix systems because platform-specific functions likeIsWindows()andOpenURL()are only defined in files for Linux (sysutil_linux.go), Darwin (sysutil_darwin.go), and Windows (sysutil_windows.go). When building on FreeBSD or other Unix variants, these functions are undefined, causing compilation errors:Solution
Created a new
sysutil_unix.gofile with build constraints//go:build freebsd || openbsd || netbsd || dragonflythat provides implementations for the missing functions:IsWin(),IsWindows(),IsMac(),IsDarwin(),IsLinux()all returnfalsefor these Unix systemsxdg-open,x-www-browser, and fallback browsersruntime.GOOSto return the actual OS name (freebsd, openbsd, netbsd, dragonfly)Testing
Validated the fix through cross-compilation testing:
The implementation follows the same patterns as existing platform-specific files and maintains backward compatibility.
Fixes #230.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.