add: macOS open browser

This commit is contained in:
BaoXuebin 2021-12-15 22:39:07 +08:00 committed by leo
parent 0beb50fadc
commit f87a25d75e
2 changed files with 11 additions and 0 deletions

BIN
beancount-gs Executable file

Binary file not shown.

View File

@ -10,6 +10,11 @@ func isWindows() bool {
return os == "windows"
}
func isMacOS() bool {
os := runtime.GOOS
return os == "darwin"
}
func OpenBrowser(url string) {
if isWindows() {
cmd := exec.Command("cmd", "/C", "start", url)
@ -17,5 +22,11 @@ func OpenBrowser(url string) {
if err != nil {
LogSystemError("Failed to open browser, error is " + err.Error())
}
} else if isMacOS() {
cmd := exec.Command("open", url)
err := cmd.Start()
if err != nil {
LogSystemError("Failed to open browser, error is " + err.Error())
}
}
}