browser

package
v1.211.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChromeInfo

type ChromeInfo struct {
	// Path is the full path to the Chrome executable.
	Path string
	// UseMacOSOpen indicates whether to use the macOS `open -na` pattern.
	UseMacOSOpen bool
	// AppName is the application name for macOS `open -na` (e.g., "Google Chrome").
	AppName string
}

ChromeInfo holds information about a detected Chrome/Chromium installation.

func DetectChrome

func DetectChrome() (*ChromeInfo, error)

DetectChrome finds a Chrome or Chromium installation on the system. Returns ErrChromeNotFound if no installation is found.

type CommandRunner

type CommandRunner interface {
	// Run starts the command and does not wait for it to complete.
	Run(name string, args ...string) error
}

CommandRunner executes external commands. Abstracted for testing.

type Opener

type Opener interface {
	// Open opens the given URL in a browser.
	Open(url string) error
}

Opener opens URLs in a browser.

func New

func New(opts ...Option) Opener

New returns an Opener configured with the given options. When WithIsolatedSession is provided and Chrome is available, returns an isolated opener. Otherwise, returns a default system-browser opener.

type Option

type Option func(*config)

Option configures browser opening behavior.

func WithCommandRunner

func WithCommandRunner(runner CommandRunner) Option

WithCommandRunner sets a custom command runner (for testing).

func WithIsolatedSession

func WithIsolatedSession(sessionDir string) Option

WithIsolatedSession enables isolated browser sessions using the given directory as Chrome's user data directory. The caller is responsible for creating the directory and choosing an appropriate path (e.g., based on realm, identity, or any other session key).

Jump to

Keyboard shortcuts

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