diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-04 08:38:59 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:22 +0200 |
| commit | 9ca26cb701e0c4d5a9cbcdae7cc376c4e356d2d6 (patch) | |
| tree | 76b9eceb1328ed75aaedfda0010f27202c771a3b | |
| parent | ecc91eba435c4071b28a462287ea8a0e1fea12e6 (diff) | |
| download | muhqs-game-9ca26cb701e0c4d5a9cbcdae7cc376c4e356d2d6.tar.gz muhqs-game-9ca26cb701e0c4d5a9cbcdae7cc376c4e356d2d6.zip | |
support js/wasm for openUrl
| -rw-r--r-- | go/ui/openUrl.go | 5 | ||||
| -rw-r--r-- | go/ui/openUrl_wasm.go | 12 |
2 files changed, 16 insertions, 1 deletions
diff --git a/go/ui/openUrl.go b/go/ui/openUrl.go index 7e227ba8..7d429577 100644 --- a/go/ui/openUrl.go +++ b/go/ui/openUrl.go @@ -1,3 +1,6 @@ +//go:build !wasm +// +build !wasm + package ui import ( @@ -6,7 +9,7 @@ import ( ) // 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. +// OpenUrl opens the specified URL in the default browser of the user. func OpenUrl(url string) error { var cmd string var args []string diff --git a/go/ui/openUrl_wasm.go b/go/ui/openUrl_wasm.go new file mode 100644 index 00000000..d88de6bf --- /dev/null +++ b/go/ui/openUrl_wasm.go @@ -0,0 +1,12 @@ +package ui + +import ( + "syscall/js" +) + +// OpenUrl opens the specified URL using `window.open`. +func OpenUrl(url string) error { + w := js.Global().Get("window") + w.Call("open", url) + return nil +} |
