diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-04 08:38:59 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-07-06 11:49:19 -0400 |
| commit | 8c195e0d0facb28dfac75ae82163ab5baf843a6b (patch) | |
| tree | dfd3ab61a5885bb69934732fb29cb3fb8d30eff8 | |
| parent | b7c9097af50301362673b829feb7674d2c7e0722 (diff) | |
| download | muhqs-game-8c195e0d0facb28dfac75ae82163ab5baf843a6b.tar.gz muhqs-game-8c195e0d0facb28dfac75ae82163ab5baf843a6b.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 +} |
