Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inkeliz/giohyperlink
Brings the <a href> to Gio. Small library to open URLs, supports Android, Windows, Linux, FreeBSD, iOS, macOS and WASM
https://github.com/inkeliz/giohyperlink
browser golang
Last synced: about 2 months ago
JSON representation
Brings the <a href> to Gio. Small library to open URLs, supports Android, Windows, Linux, FreeBSD, iOS, macOS and WASM
- Host: GitHub
- URL: https://github.com/inkeliz/giohyperlink
- Owner: inkeliz
- License: other
- Created: 2020-11-09T23:20:58.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-03T21:54:51.000Z (over 2 years ago)
- Last Synced: 2024-05-22T12:31:53.775Z (7 months ago)
- Topics: browser, golang
- Language: Go
- Homepage:
- Size: 84 KB
- Stars: 10
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gio - Hyperlink
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:
```rust
```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:
```go
giohyperlink.Open("https://github.com")
```That will open the link in the default browser. You can use `OpenURL` to open a `*url.URL`:
```go
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.