mirror of https://github.com/miguelmota/cointop
check for xdg-open
Former-commit-id: 30078d5077102d423c9bd9e9f471f13292d03476 [formerly 30078d5077102d423c9bd9e9f471f13292d03476 [formerly e4d6dd14852be385787f940fde94e0c8379020d0 [formerly 35c4dca299
]]]
Former-commit-id: 4f37e12ff7ba15cea5dcc6fc83e5e79a27ccbcb8
Former-commit-id: 07c4ee19000bbb5f1294b66781b327ddfaa94d27 [formerly 8087f44df69fee4ba7c9c0610501556bf852ddfe]
Former-commit-id: 2d68d8de8d634126292962509b9f0e91142a496d
pull/15/head
parent
406226ab46
commit
07b7defed6
@ -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