mirror of
https://github.com/miguelmota/cointop
synced 2024-11-18 15:25:31 +00:00
07b7defed6
Former-commit-id: 30078d5077102d423c9bd9e9f471f13292d03476 [formerly 30078d5077102d423c9bd9e9f471f13292d03476 [formerly e4d6dd14852be385787f940fde94e0c8379020d0 [formerly 35c4dca299
]]]
Former-commit-id: 4f37e12ff7ba15cea5dcc6fc83e5e79a27ccbcb8
Former-commit-id: 07c4ee19000bbb5f1294b66781b327ddfaa94d27 [formerly 8087f44df69fee4ba7c9c0610501556bf852ddfe]
Former-commit-id: 2d68d8de8d634126292962509b9f0e91142a496d
35 lines
491 B
Go
35 lines
491 B
Go
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
|
|
}
|