browser

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package browser opens a URL in the person's default browser with the platform's own opener: xdg-open on Linux and the BSDs, open on macOS, and url.dll's FileProtocolHandler through rundll32 on Windows (which, unlike `cmd /c start`, needs no quoting of & in a URL).

It reports ErrUnavailable instead of trying when there is clearly no way to show a browser — no opener on PATH, or a Linux session with no display (SSH, containers, CI) — so callers fall back to printing the link (spec/features/local-server-and-web-console#REQ:login-links).

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("no browser can be opened from here")

ErrUnavailable means no browser can be launched from this process.

Functions

func Command

func Command(goos, url string) (name string, args []string)

Command is the opener and its arguments for url on goos.

Types

type Opener

type Opener struct {
	GOOS     string                                  // runtime.GOOS when empty
	Getenv   func(string) string                     // os.Getenv when nil
	LookPath func(string) (string, error)            // exec.LookPath when nil
	Start    func(name string, args ...string) error // starts without waiting when nil
}

Opener launches browsers. The zero value uses the real environment.

func (Opener) Open

func (o Opener) Open(url string) error

Open launches the default browser at url and returns without waiting for it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL