mirror of
https://github.com/fumiama/go-web-wrapper.git
synced 2026-06-10 04:50:38 +08:00
init
This commit is contained in:
30
main_unix.go
Normal file
30
main_unix.go
Normal 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 {}
|
||||
}
|
||||
Reference in New Issue
Block a user