mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 03:27:02 -07:00
Refactored and reorganized code
This commit is contained in:
parent
86f8784c19
commit
fdb0db389c
8 changed files with 384 additions and 127 deletions
|
|
@ -5,6 +5,8 @@ import (
|
|||
"math/rand"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -58,3 +60,22 @@ func PathExists(path string) (bool, error) {
|
|||
}
|
||||
return false, err
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/39320371/how-start-web-server-to-open-page-in-browser-in-golang
|
||||
// open opens the specified URL in the default browser of the user.
|
||||
func OpenUrl(url string) error {
|
||||
var cmd string
|
||||
var args []string
|
||||
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
cmd = "cmd"
|
||||
args = []string{"/c", "start"}
|
||||
case "darwin":
|
||||
cmd = "open"
|
||||
default: // "linux", "freebsd", "openbsd", "netbsd"
|
||||
cmd = "xdg-open"
|
||||
}
|
||||
args = append(args, url)
|
||||
return exec.Command(cmd, args...).Start()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue