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-07-03 22:01:22 -0400
commit154cf56c5deafb8bcbdef925775c9c565d7f6362 (patch)
treef8c243cfd630f4041753d146bccb276b577c41c2 /go/ui
parent88c6df9aed06a53edd6ef463dd1daf877b85ed0a (diff)
downloadmuhqs-game-154cf56c5deafb8bcbdef925775c9c565d7f6362.tar.gz
muhqs-game-154cf56c5deafb8bcbdef925775c9c565d7f6362.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()
+}