mirror of https://github.com/miguelmota/cointop
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
516 B
Go
36 lines
516 B
Go
package open
|
|
|
|
import (
|
|
"os/exec"
|
|
)
|
|
|
|
var openCmd string
|
|
var possibleCmds = []string{
|
|
"xdg-open", // linux
|
|
"open", // mac
|
|
"start", // windows?
|
|
"cygstart", // windows?
|
|
}
|
|
|
|
func init() {
|
|
for i, cmd := range possibleCmds {
|
|
out, err := exec.Command("command", "-v", cmd).Output()
|
|
if err != nil {
|
|
continue
|
|
}
|
|
|
|
bin := string(out)
|
|
if bin != "" {
|
|
openCmd = possibleCmds[i]
|
|
}
|
|
}
|
|
}
|
|
|
|
// URL open url
|
|
func URL(s string) error {
|
|
if openCmd != "" {
|
|
exec.Command(openCmd, s).Output()
|
|
}
|
|
return nil
|
|
}
|