Categorygithub.com/inkeliz/giohyperlink
repositorypackage
0.0.0-20220903215451-2ac5d54abdce
Repository: https://github.com/inkeliz/giohyperlink.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

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.