mirror of https://github.com/miguelmota/cointop
check for xdg-open
parent
6352072050
commit
35c4dca299
@ -0,0 +1,34 @@
|
||||
package open
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
var openCmd string
|
||||
var possibleCmds = []string{
|
||||
"xdg-open", // linux
|
||||
"open", // mac
|
||||
"start", // 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
|
||||
}
|
Loading…
Reference in New Issue