mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 14:06:36 +08:00
24 lines
419 B
Go
24 lines
419 B
Go
package utils
|
|
|
|
import (
|
|
"log/slog"
|
|
"os/exec"
|
|
"runtime"
|
|
)
|
|
|
|
func OpenBrowser(url string) {
|
|
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()
|
|
}
|
|
if err != nil {
|
|
slog.Error("open browser failed", "error", err)
|
|
}
|
|
}
|