dorfylegends/backend/server/util.go

28 lines
505 B
Go
Raw Normal View History

2022-04-26 10:24:16 +03:00
package server
import (
"fmt"
"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()
default:
err = fmt.Errorf("unsupported platform")
}
if err != nil {
fmt.Println(err)
fmt.Println("navigate to http://localhost:8080 in your browser")
}
}