Files
wehub-resource-sync ead81af521
Deploy to GitHub Pages / deploy (push) Failing after 0s
CI / go (push) Has been cancelled
CI / build (darwin, macos-14) (push) Has been cancelled
CI / build (windows, windows-2025) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:13 +08:00

22 lines
437 B
Go

package browser
import (
"fmt"
"os/exec"
"runtime"
)
// Open tries to open a URL in the user's default browser.
func Open(u string) error {
switch runtime.GOOS {
case "darwin":
return exec.Command("open", u).Start()
case "linux":
return exec.Command("xdg-open", u).Start()
case "windows":
return exec.Command("rundll32", "url.dll,FileProtocolHandler", u).Start()
default:
return fmt.Errorf("unsupported platform")
}
}