Sha256: 0df707d84105ede8a99632102a541f3c721f7b6a7c97af65699fe7e78f4d94b5
Contents?: true
Size: 563 Bytes
Versions: 16
Compression:
Stored size: 563 Bytes
Contents
package browser import ( "os/exec" "strings" ) func openBrowser(url string) error { providers := []string{"xdg-open", "x-www-browser", "www-browser"} // There are multiple possible providers to open a browser on linux // One of them is xdg-open, another is x-www-browser, then there's www-browser, etc. // Look for one that exists and run it for _, provider := range providers { if _, err := exec.LookPath(provider); err == nil { return runCmd(provider, url) } } return &exec.Error{Name: strings.Join(providers, ","), Err: exec.ErrNotFound} }
Version data entries
16 entries across 16 versions & 1 rubygems