You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
443 B
26 lines
443 B
package util |
|
|
|
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) { |
|
program, args := GetDefaultForOS() |
|
args = append(args, url) |
|
exec.Command(program, args...).Start() |
|
}
|
|
|