StartBrowser tries to open the URL in a browser and reports whether it succeeds. Orig. code: golang.org/x/tools/cmd/cover/html.go
(url string)
| 83 | // |
| 84 | // Orig. code: golang.org/x/tools/cmd/cover/html.go |
| 85 | func StartBrowser(url string) bool { |
| 86 | // try to start the browser |
| 87 | var args []string |
| 88 | switch runtime.GOOS { |
| 89 | case "darwin": |
| 90 | args = []string{"open"} |
| 91 | case "windows": |
| 92 | args = []string{"cmd", "/c", "start"} |
| 93 | default: |
| 94 | args = []string{"xdg-open"} |
| 95 | } |
| 96 | cmd := exec.Command(args[0], append(args[1:], url)...) |
| 97 | fmt.Println("If browser window didn't appear, please go to this url:", url) |
| 98 | return cmd.Start() == nil |
| 99 | } |