mirror of
https://github.com/onyx-dot-app/onyx.git
synced 2026-10-23 03:42:59 -05:00
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
30 lines
667 B
Go
30 lines
667 B
Go
// Package util provides shared utility functions.
|
|
package util
|
|
|
|
import (
|
|
"os/exec"
|
|
"runtime"
|
|
)
|
|
|
|
// OpenBrowser opens the given URL in the user's default browser.
|
|
// Returns true if the browser was launched successfully.
|
|
func OpenBrowser(url string) bool {
|
|
var cmd *exec.Cmd
|
|
switch runtime.GOOS {
|
|
case "darwin":
|
|
cmd = exec.Command("open", url)
|
|
case "linux":
|
|
cmd = exec.Command("xdg-open", url)
|
|
case "windows":
|
|
cmd = exec.Command("rundll32", "url.dll,FileProtocolHandler", url)
|
|
}
|
|
if cmd != nil {
|
|
if err := cmd.Start(); err == nil {
|
|
// Reap the child process to avoid zombies.
|
|
go func() { _ = cmd.Wait() }()
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|