openBrowser opens the specified URL in the user's default browser
(url string)
| 285 | |
| 286 | // openBrowser opens the specified URL in the user's default browser |
| 287 | func openBrowser(url string) { |
| 288 | var cmd string |
| 289 | var args []string |
| 290 | |
| 291 | switch runtime.GOOS { |
| 292 | case "windows": |
| 293 | cmd = "cmd" |
| 294 | args = []string{"/c", "start"} |
| 295 | case "darwin": |
| 296 | cmd = "open" |
| 297 | default: // "linux", "freebsd", "openbsd", "netbsd" |
| 298 | cmd = "xdg-open" |
| 299 | } |
| 300 | |
| 301 | args = append(args, url) |
| 302 | |
| 303 | if err := exec.Command(cmd, args...).Start(); err != nil { |
| 304 | log.Printf("🌐 Unable to auto-open browser: %v", err) |
| 305 | log.Printf("🌐 Please manually open: %s", url) |
| 306 | } else { |
| 307 | log.Printf("🚀 Dashboard opening in your browser...") |
| 308 | } |
| 309 | } |