Skip to content

Repository files navigation

GioHyperlink

Opens a hyperlink in the default browser. 🤩

Setup

First, you need to go get github.com/inkeliz/giohyperlink, then you need to provide giohyperlink access to the Window events, so you need to add the following to your main loop function:

```diff
 for evt := range w.Events() { // Gio main event loop
+    giohyperlink.ListenEvents(e)

    switch evt := evt.(type) {
        // ...
    }
}

⚠️In some OSes (Windows, macOS...) this setup is optional, but it's recommended to do it anyway.

Usage

To open one link, you can use the Open function:

giohyperlink.Open("https://github.com")

That will open the link in the default browser. You can use OpenURL to open a *url.URL:

giohyperlink.OpenURL(&url.URL{
    Scheme: "https",
    Host:   "github.com",
})

By default only HTTP and HTTPS links are allowed, but you can change that by changing InsecureIgnoreScheme to true, you should validate the URL and scheme on your own.

About

Brings the <a href> to Gio. Small library to open URLs, supports Android, Windows, Linux, FreeBSD, iOS, macOS and WASM

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages