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 ¶
var ErrEmptyURL = fmt.Errorf("browser: URL must not be empty")
ErrEmptyURL is returned when an empty URL is passed to Open.
Functions ¶
func Open ¶
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 ¶
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.
Types ¶
This section is empty.