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.
- Host: GitHub
- URL: https://github.com/jasonlovesdoggo/gopen
- Owner: JasonLovesDoggo
- License: mit
- Created: 2025-01-30T10:06:26.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-30T10:56:08.000Z (5 months ago)
- Last Synced: 2025-02-25T18:45:01.806Z (4 months ago)
- Topics: cli, cross-platform, go, golang, library, open, openurl, tool, url
- Language: Go
- Homepage: https://pkg.go.dev/github.com/jasonlovesdoggo/gopen
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gopen
A lightweight, cross-platform Go library for opening URLs in the system's default browser.
[](https://pkg.go.dev/github.com/jasonlovesdoggo/gopen)
[](https://github.com/jasonlovesdoggo/gopen/actions)
[](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 mainimport (
"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