1
0
mirror of https://github.com/fumiama/go-web-wrapper.git synced 2026-06-05 00:32:43 +08:00
Files
go-web-wrapper/main_unix.go
源文雨 28dca5ac1e init
2025-07-16 22:59:58 +09:00

31 lines
417 B
Go

//go:build unix
package main
import (
"errors"
"os/exec"
"runtime"
)
func openBrowser(url string) error {
var cmd string
switch runtime.GOOS {
case "darwin":
cmd = "open"
case "linux":
cmd = "xdg-open"
default:
return errors.New("unsupported platform")
}
return exec.Command(cmd, url).Start()
}
func main() {
err := openBrowser("http://" + Endpoint)
if err != nil {
panic(err)
}
select {}
}