browser

package
v0.2.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package browser provides cross-platform browser-opening utilities for the StackEye CLI. It supports macOS (open), Linux (xdg-open), and Windows (rundll32), with a graceful fallback that prints the URL when the browser cannot be opened.

Usage:

if err := browser.Open("https://app.stackeye.io"); err != nil {
    // handle error
}

// Or with automatic fallback to printing the URL:
browser.OpenOrPrint("https://app.stackeye.io")

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyURL = fmt.Errorf("browser: URL must not be empty")

ErrEmptyURL is returned when an empty URL is passed to Open.

Functions

func Open

func Open(rawURL string) error

Open opens the given URL in the user's default browser. It validates the URL and returns an error if the URL is empty, unparseable, has a disallowed scheme, or the browser command fails to start. Only http and https URLs are permitted.

func OpenOrPrint

func OpenOrPrint(rawURL string) error

OpenOrPrint attempts to open the URL in a browser. If the browser fails to open, it prints the URL to stderr so the user can open it manually. This never returns an error for browser launch failures - only for invalid input. Only http and https URLs are permitted.

func SetOpener

func SetOpener(fn func(string) error)

SetOpener replaces the function used to launch URLs. Pass nil to restore the default platform-specific behaviour. Intended for testing only.

Types

This section is empty.

Jump to

Keyboard shortcuts

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