3 changed files with 32 additions and 8 deletions
@ -1,7 +1,26 @@
|
||||
package util |
||||
|
||||
import "os/exec" |
||||
import ( |
||||
"os/exec" |
||||
"runtime" |
||||
) |
||||
|
||||
func GetDefaultForOS() (program string, args []string) { |
||||
switch runtime.GOOS { |
||||
case "windows": |
||||
program = "start" |
||||
args = []string{"/wait"} |
||||
case "darwin": |
||||
program = "open" |
||||
args = []string{"-W"} |
||||
default: |
||||
program = "xdg-open" |
||||
} |
||||
return program, args |
||||
} |
||||
|
||||
func OpenURL(url string) { |
||||
exec.Command("xdg-open", url).Start() |
||||
program, args := GetDefaultForOS() |
||||
args = append(args, url) |
||||
exec.Command(program, args...).Start() |
||||
} |
||||
|
||||
Loading…
Reference in new issue