Created
May 20, 2019 09:43
-
-
Save nanmu42/4fbaf26c771da58095fa7a9f14f23d27 to your computer and use it in GitHub Desktop.
Golang: Open URL in Browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func openBrowser(url string) { | |
var err error | |
switch runtime.GOOS { | |
case "linux": | |
err = exec.Command("xdg-open", url).Start() | |
case "windows": | |
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() | |
case "darwin": | |
err = exec.Command("open", url).Start() | |
default: | |
err = fmt.Errorf("unsupported platform") | |
} | |
if err != nil { | |
log.Fatal(err) | |
} | |
} |
As far as I know, no.
Maybe use a token in query string?
Yes I will have to do a workaround. Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way to pass an authentication header? Like the
-H
option incurl