aboutsummaryrefslogtreecommitdiff
path: root/go/ui
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-06-06 16:42:46 -0500
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:18 +0200
commitbcffeac4c5086eba59448d4fe5d79bb786b05de2 (patch)
treecc0b3648f2b070c731225e88b42fb3f4adcb65da /go/ui
parentc15142c3bcae4316c8580adb7a9f0b223e586ae9 (diff)
downloadmuhqs-game-bcffeac4c5086eba59448d4fe5d79bb786b05de2.tar.gz
muhqs-game-bcffeac4c5086eba59448d4fe5d79bb786b05de2.zip
refactor client activities
Make the activity stack explicit and move reusable activities to the activity package.
Diffstat (limited to 'go/ui')
-rw-r--r--go/ui/openUrl.go25
1 files changed, 25 insertions, 0 deletions
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()
+}