Open tries to open url in a browser and reports whether it succeeded.
(url string)
| 42 | |
| 43 | // Open tries to open url in a browser and reports whether it succeeded. |
| 44 | func Open(url string) bool { |
| 45 | for _, args := range Commands() { |
| 46 | cmd := exec.Command(args[0], append(args[1:], url)...) |
| 47 | if cmd.Start() == nil && appearsSuccessful(cmd, 3*time.Second) { |
| 48 | return true |
| 49 | } |
| 50 | } |
| 51 | return false |
| 52 | } |
| 53 | |
| 54 | // appearsSuccessful reports whether the command appears to have run successfully. |
| 55 | // If the command runs longer than the timeout, it's deemed successful. |
no test coverage detected