Files
LazyPM/internal/utils/browser.go
2026-02-26 18:54:51 +01:00

25 lines
491 B
Go

package utils
import (
"fmt"
"os/exec"
"runtime"
)
// Taken and modified from https://gist.github.com/hyg/9c4afcd91fe24316cbf0
func OpenBrowser(url string) error {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
default:
err = fmt.Errorf("unsupported platform")
}
return err
}