2021-12-01 11:18:20 -05:00
|
|
|
//go:build darwin
|
2020-06-18 16:54:48 -04:00
|
|
|
// +build darwin
|
|
|
|
|
|
|
|
package webbrowser
|
|
|
|
|
|
|
|
import "os/exec"
|
|
|
|
|
2020-10-01 17:06:50 -04:00
|
|
|
// Open opens `url` in default system browser.
|
2020-06-18 16:54:48 -04:00
|
|
|
func Open(url string) (string, error) {
|
2021-12-22 17:49:07 -05:00
|
|
|
proc := exec.Command("open", url)
|
|
|
|
err := proc.Start()
|
2020-06-18 16:54:48 -04:00
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
2021-12-22 20:39:17 -05:00
|
|
|
//nolint:errcheck
|
2021-12-22 17:49:07 -05:00
|
|
|
go proc.Wait() // Prevent zombies, see #219
|
2020-06-18 16:54:48 -04:00
|
|
|
return "Opened in system default web browser", nil
|
|
|
|
}
|