browser_go is a lightweight, cross-platform Go package that lets you open URLs in the user's default web browser. It supports Windows, macOS, Linux, and Windows Subsystem for Linux (WSL).
When developing web applications or APIs (for example, with the Gin web framework), you often want your dashboard or homepage to open automatically in the browser as soon as your server starts.
browser_go makes this effortless and improves your development workflow.
- Cross-platform: Works seamlessly on Windows, macOS, Linux, and WSL.
- WSL-aware: Detects WSL and opens URLs in the native Windows browser.
- Simple API: Just call
OpenURLwith your URL. - No external dependencies: Uses only Go’s standard library and built-in system utilities.
Install the package with:
go get github.com/Abin-Antu/browser_goYou can use browser_go to open any web page—such as your dashboard, API UI, or documentation—automatically when your Go web server starts.
package main
import (
"github.com/Abin-Antu/browser_go/browser"
)
func main() {
url := "http://localhost:8080/dashboard"
browser.OpenURL(url) // This will open the dashboard in the default browser
// Start your web server here (example with Gin or net/http)
// router := gin.Default()
// router.Run(":8080")
}Just call browser.OpenURL(url) with the URL you want to open.
This is especially handy for automatically launching your web dashboard, homepage, or API documentation for local development.
MIT License. See LICENSE for details.