From 9ca26cb701e0c4d5a9cbcdae7cc376c4e356d2d6 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 4 Jul 2025 08:38:59 -0400 Subject: support js/wasm for openUrl --- go/ui/openUrl.go | 5 ++++- go/ui/openUrl_wasm.go | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 go/ui/openUrl_wasm.go 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 +} -- cgit v1.2.3