Improve checkOS method for better handling existing browser
Bunchhieng opened this issue · 4 comments
Bunchhieng commented
Current code
func checkOS() string {
chrome := ""
if runtime.GOOS == "windows" {
chrome = "chrome"
} else if runtime.GOOS == "darwin" {
chrome = "Google Chrome"
}
return chrome
}
kolten commented
Suggestion/slightly outside of this issue: Instead of having the user specify a browser, what about executing a system command to open their default browser?
Bunchhieng commented
zpeters commented
We might be able to simplify browser selection. Let me know what you think.
#1 if the user specifies --browser explicitly use that exact path/command
#2 if no #1, then find the users default browser. For Macos i believe you can use "open http://myurl" and it will launch with the default browser. For windows and linux there is probably something similar
This could potentially simplify your code in the future.
What do you think?
sarlalian commented
For windows I believe it is "start http://myurl" and for linux it is "xdg-open http://myurl"