1
0
mirror of https://github.com/fumiama/go-web-wrapper.git synced 2026-06-10 04:50:38 +08:00
This commit is contained in:
源文雨
2025-07-16 22:59:58 +09:00
parent 59331ed177
commit 28dca5ac1e
7 changed files with 351 additions and 0 deletions

30
main_unix.go Normal file
View File

@@ -0,0 +1,30 @@
//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 {}
}