diff --git a/browser_js.go b/browser_js.go new file mode 100644 index 0000000..2438700 --- /dev/null +++ b/browser_js.go @@ -0,0 +1,14 @@ +package browser + +import ( + "fmt" + "syscall/js" +) + +func openBrowser(url string) error { + window := js.Global().Get("window").Call("open", url, "_blank") + if !window.Truthy() { + return fmt.Errorf("Unable to open tab, check browser logs") + } + return nil +} diff --git a/browser_unsupported.go b/browser_unsupported.go index 7c5c17d..461bbf9 100644 --- a/browser_unsupported.go +++ b/browser_unsupported.go @@ -1,4 +1,5 @@ -// +build !linux,!windows,!darwin,!openbsd,!freebsd,!netbsd +//go:build !linux && !windows && !darwin && !openbsd && !freebsd && !netbsd && !js +// +build !linux,!windows,!darwin,!openbsd,!freebsd,!netbsd,!js package browser