browser

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package browser provides utilities for opening URLs in the system's default browser. This package can be used by applications that need to detect browser availability or open URLs as part of authentication flows or other user interactions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanOpen

func CanOpen() bool

CanOpen checks if we can open a browser in the current environment. Returns true if the required browser command exists for the current operating system. This is useful for determining whether to attempt automatic browser opening or to fall back to displaying instructions to the user.

func Open

func Open(urlStr string) error

Open attempts to open a URL in the system's default browser. Returns an error if the URL is invalid, the platform is unsupported, or the browser command fails to execute.

The URL is validated before opening to ensure it uses http or https scheme and does not contain embedded credentials or control characters.

Security considerations:

  • Only http and https URL schemes are allowed
  • URLs are validated and sanitized before execution
  • Commands are executed with proper argument separation to prevent injection
  • The browser process runs independently and does not block the caller

Types

This section is empty.

Jump to

Keyboard shortcuts

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