An open API service indexing awesome lists of open source software.

https://github.com/jasonlovesdoggo/gopen

A lightweight, cross-platform Go library for opening URLs in the system's default browser.
https://github.com/jasonlovesdoggo/gopen

cli cross-platform go golang library open openurl tool url

Last synced: 3 months ago
JSON representation

A lightweight, cross-platform Go library for opening URLs in the system's default browser.

Awesome Lists containing this project

README

        

# gopen

A lightweight, cross-platform Go library for opening URLs in the system's default browser.

[![Go Reference](https://pkg.go.dev/badge/github.com/jasonlovesdoggo/gopen.svg)](https://pkg.go.dev/github.com/jasonlovesdoggo/gopen)
[![Test Status](https://github.com/jasonlovesdoggo/gopen/workflows/Test/badge.svg)](https://github.com/jasonlovesdoggo/gopen/actions)
[![Go Report Card](https://goreportcard.com/badge/github.com/jasonlovesdoggo/gopen)](https://goreportcard.com/report/github.com/jasonlovesdoggo/gopen)

## Features

- Extensive platform support
- Non-blocking operation
- Zero dependencies
- Simple, clean API
- Thoroughly tested

## Installation
### Library
```bash
go get github.com/jasonlovesdoggo/gopen
```

### CLI
```bash
go install github.com/jasonlovesdoggo/gopen/cmd/gopen@latest
````

## Usage

### Library
```go
package main

import (
"fmt"
"github.com/jasonlovesdoggo/gopen"
)

func main() {
err := gopen.Open("https://github.com")
if err != nil {
fmt.Printf("Failed to open URL: %v\n", err)
}
}
```

### CLI
```bash
gopen https://jasoncameron.dev
```

## Platform Support

### Windows
- Supported architectures: 386, amd64, arm, arm64
- Uses `cmd /c start` command

### macOS (Darwin)
- Supported architectures: amd64, arm64
- Uses `open` command

### iOS
- Supported architectures: amd64, arm64
- Uses `uiopen` command

### Android
- Supported architectures: 386, amd64, arm, arm64
- Uses Android intent system

### Unix-like Systems
Supports the following operating systems and architectures:
- Linux (386, amd64, arm, arm64, ppc64, ppc64le, mips, mips64, mips64le, mipsle, riscv64, s390x)
- FreeBSD (386, amd64, arm, arm64)
- OpenBSD (386, amd64, arm, arm64)
- NetBSD (386, amd64, arm, arm64)
- DragonFly BSD (amd64)
- Solaris (amd64)
- illumos (amd64)
- AIX (ppc64)

For Unix-like systems, the following browsers are tried in order:
1. `wslview` (Windows Subsystem for Linux)
2. `xdg-open` (Generic X11)
3. `sensible-browser` (Debian/Ubuntu)
4. `firefox` (Mozilla Firefox)
5. `google-chrome` (Google Chrome)
6. `chromium` (Chromium)
7. `chromium-browser` (Chromium alternative)
8. `safari` (Safari)
9. `opera` (Opera)
10. `epiphany` (GNOME Web)

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

MIT License - see the [LICENSE](LICENSE) file for details.

## Credits

This project was inspired by the Rust [open-rs](https://github.com/Byron/open-rs) crate and [this](https://stackoverflow.com/questions/39320371/how-start-web-server-to-open-page-in-browser-in-golang) stack overflow post