browserutil

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Refusal of anything but an absolute http or https URL with a host, which could otherwise reach a command line as an option or make an opener run a local program
	ErrUnsafeURL = errors.New("not an absolute http or https url")
	// Failure of every launcher, or no launcher at all, to take the URL
	ErrNoBrowser = errors.New("no browser opened the url")
)

Functions

func Open

func Open(ctx context.Context, target string) error

Shows an absolute http or https URL in the user's browser, trying each BROWSER entry and then the openers of this platform until one takes it; ErrUnsafeURL for anything else

Types

type Launcher

type Launcher struct {
	Args       []string // program and arguments, each %s standing for the URL: inside a shell's -c command string a quoted reference to the BROWSER_URL variable set for it, inside PowerShell code the URL as a quoted literal, elsewhere the URL itself within that one argument
	Terminal   bool     // a text browser running in this terminal: Open waits for it and its exit status decides
	Background bool     // a BROWSER entry ending in &: started and left running without waiting for an early failure
}

One way Open can show a URL, a command line or, with no Args, the operating system's own URL handler

func Launchers

func Launchers() []Launcher

Launchers Open tries, in order: each entry of BROWSER, then the openers of this platform found on this host

Jump to

Keyboard shortcuts

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