mirror of
https://github.com/fumiama/go-web-wrapper.git
synced 2026-06-05 00:32:43 +08:00
31 lines
417 B
Go
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 {}
|
|
}
|