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.
cointop/pkg/open/open.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
}