From bcffeac4c5086eba59448d4fe5d79bb786b05de2 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 6 Jun 2025 16:42:46 -0500 Subject: refactor client activities Make the activity stack explicit and move reusable activities to the activity package. --- go/ui/openUrl.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 go/ui/openUrl.go (limited to 'go/ui') diff --git a/go/ui/openUrl.go b/go/ui/openUrl.go new file mode 100644 index 00000000..7e227ba8 --- /dev/null +++ b/go/ui/openUrl.go @@ -0,0 +1,25 @@ +package ui + +import ( + "os/exec" + "runtime" +) + +// https://stackoverflow.com/questions/39320371/how-start-web-server-to-open-page-in-browser-in-golang +// open opens the specified URL in the default browser of the user. +func OpenUrl(url string) error { + var cmd string + var args []string + + switch runtime.GOOS { + case "windows": + cmd = "cmd" + args = []string{"/c", "start"} + case "darwin": + cmd = "open" + default: // "linux", "freebsd", "openbsd", "netbsd" + cmd = "xdg-open" + } + args = append(args, url) + return exec.Command(cmd, args...).Start() +} -- cgit v1.2.3