browser

A minimal Go library for opening files, readers, and URLs in the user's default browser.

Library
Go
vv0.0.0-20240102092130-5ac0b6a4141c
618 stars
BSD-2-Clause

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
37 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 68
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
51 /100 Fair
Architecture 75
Code Quality 45
Innovation 30
Learning Curve 55

pkg/browser is a small Go package that opens files, io.Reader contents, or URLs in the user’s default web browser. It exposes three functions — OpenFile, OpenReader, and OpenURL — that hide the platform-specific mechanics of invoking a browser, whether that’s macOS’s open, Windows’ ShellExecute syscall, or Linux’s xdg-open/x-www-browser/www-browser fallback chain.

Rather than shipping opinions about which browser to launch, it defers entirely to the client machine’s default handler, making it a thin, dependable primitive for Go CLIs and tools that need to hand off to a browser — for example opening a generated HTML report, a local dev server, or an OAuth login page.

What You Get

  • OpenURL - opens a new browser window pointed at any URL using the OS’s native handler.
  • OpenFile - resolves a local file path to an absolute file:// URL and opens it in the browser.
  • OpenReader - writes the contents of any io.Reader to a temporary HTML file and opens it, useful for rendering generated content on the fly without managing a temp file yourself.
  • Cross-platform dispatch - platform-specific build files (browser_darwin.go, browser_linux.go, browser_windows.go, browser_freebsd.go, browser_netbsd.go, browser_openbsd.go, browser_unsupported.go) select the right open mechanism at compile time via Go build tags.

Common Use Cases

  • CLI tools that open a login page - a command-line OAuth flow that needs to hand the user off to a browser for authentication.
  • Local dev servers - a Go program that starts a local web server and immediately opens it in the browser for the developer.
  • Rendering generated reports - a build or test tool that produces an HTML report and opens it directly via OpenReader without writing to a permanent file.
  • Documentation generators - godoc-style tools that open freshly generated docs in the browser.

Under The Hood

Architecture

The package is a single flat browser package built around three exported entry points in browser.go — OpenURL, OpenFile, and OpenReader — all funneling into an unexported openBrowser(url string) error. That function has no single implementation; instead, seven OS-specific files (browser_darwin.go, browser_linux.go, browser_windows.go, browser_freebsd.go, browser_netbsd.go, browser_openbsd.go, and a browser_unsupported.go catch-all guarded by a !linux,!windows,!darwin,!openbsd,!freebsd,!netbsd build constraint) each supply their own openBrowser, and the Go compiler picks exactly one at build time. This is a clean, idiomatic use of Go’s build-tag mechanism to express a strategy pattern without runtime branching or an interface — swapping or extending platform support means adding one small file, and nothing else in the package would need to change.

Tech Stack

The module targets Go 1.14 and declares a single external dependency, golang.org/x/sys v0.1.0, used only by the Windows build to call windows.ShellExecute. There is no build tooling beyond go build/go test; CI is one GitHub Actions workflow (push.yml) that runs go test -v ./... on Go 1.15 against ubuntu-latest only, meaning the darwin and windows code paths are never exercised in CI. The package has no runtime dependencies beyond the Go standard library on non-Windows platforms.

Code Quality

Testing consists solely of example_test.go, which defines three Example* functions (ExampleOpenFile, ExampleOpenReader, ExampleOpenURL) that call each public function but include no // Output: comment, so go test runs them without asserting anything — there is effectively no verified test coverage, including no coverage of the Linux fallback chain or the unsupported-OS error path. Error handling is idiomatic Go: every public function returns an error, and OpenReader wraps failures with fmt.Errorf and descriptive context. Naming is minimal and consistent (openBrowser, runCmd). No linter configuration or CI lint step is present.

What Makes It Unique

The package is not novel — it’s a straightforward wrapper around OS-native “open a URL” invocations, comparable to Python’s webbrowser module or Node’s open package. Its two distinguishing touches are the ordered fallback chain of three Linux openers (xdg-open, x-www-browser, www-browser) and the OpenReader convenience, which removes the boilerplate of writing a reader’s contents to a temp file before opening it.

Used by 9 apps in this directory

Go
86%
Apache 2.0

Argo Workflows

Data Engineering · Devops

17,050

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

View details
96
Repo Health
90
Technical
68
Dependency
Built with
Go 86%
TypeScript 10%
Updated 6 days ago
Go
75%
AGPL 3.0

Coder

Code Editors · Developer Tools · Devops

17,157

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
91
Repo Health
90
Technical
66
Dependency
Built with
Go 75%
TypeScript 23%
Updated 5 days ago
Go
99%
Other

Crush

AI Assistants · AI Code Assistants · Developer Tools

28,781

Your terminal coding companion — wire up any LLM with LSP intelligence, MCP extensibility, and a skills system that learns your workflow.

View details
87
Repo Health
86
Technical
68
Dependency
Built with
Go 99%
Updated 5 days ago
Go
97%
Apache 2.0

infracost

Developer Tools · Devops

12,585

Infracost shows cloud cost estimates for Terraform, CloudFormation, and AWS CDK before you deploy — in your terminal, editor, AI coding agent, and pull requests.

View details
83
Repo Health
78
Technical
68
Dependency
Built with
Go 97%
Updated 1 weeks ago
Go
63%
MIT

Obot

AI Agents · Mcp

1,120

An open-source MCP platform for organizations — host MCP servers, run MCP registries, monitor usage, and build agents and chatbots on top of the Model Context Protocol from one self-hosted deployment.

View details
88
Repo Health
70
Technical
70
Dependency
Built with
Go 63%
Svelte 21%
TypeScript 15%
Updated 6 days ago
Go
72%
MIT

Ollama

AI Development · Developer Tools

184,509

Run Llama, Gemma, DeepSeek, and other open LLMs on your own machine with one command and an OpenAI-compatible API.

View details
92
Repo Health
85
Technical
67
Dependency
Built with
Go 72%
C 19%
Updated 6 days ago
Go
93%
MIT

Plandex

AI Code Assistants

15,777

An open-source, terminal-based AI coding agent built for large tasks and real codebases — with its own version control for plans, a 2M-token effective context window, and self-hosted or cloud deployment.

View details
50
Repo Health
70
Technical
67
Dependency
Built with
Go 93%
Updated 1 years ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

40,397

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 5 days ago
Go
66%
AGPL 3.0

Vikunja

Project Management

5,833

Self-hosted task management with natural-language quick-add, multiple views, and a fully documented REST API — your tasks, your infrastructure, zero lock-in.

View details
86
Repo Health
81
Technical
65
Dependency
Built with
Go 66%
TypeScript 24%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers