shell

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 10 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

Overview

Package shell hands URLs and files to the operating system: open a link in the default browser, a file with its default app, or show a file in Finder / Explorer / the file manager.

OpenURL only accepts URLs whose scheme is allowed (http, https and mailto by default; see AllowSchemes). Pages usually reach these functions through bound methods, and a page must not be able to make the app launch arbitrary protocol handlers or local programs (file:, custom schemes) just by passing a string. Paths are checked to exist.

On iOS OpenURL goes through UIApplication openURL (Safari, Mail, …), OpenPath shows a QuickLook preview (or the "Open in…" menu) and RevealPath is ErrUnsupported, as is OpenPath for folders. On Android OpenURL starts Intent.ACTION_VIEW, OpenPath does the same with a content:// URI of the host's file provider, and RevealPath and folders are ErrUnsupported.

Functions are safe from any goroutine once the app runs. They return ErrUnsupported when the backend has no shell integration and tango.ErrNotRunning after the app quit.

Index

Constants

This section is empty.

Variables

View Source
var DefaultSchemes = []string{"http", "https", "mailto"}

DefaultSchemes are the schemes OpenURL allows unless changed.

View Source
var ErrSchemeNotAllowed = errors.New("tango/shell: URL scheme not allowed")

ErrSchemeNotAllowed is returned by OpenURL for URLs whose scheme is not allowed.

View Source
var ErrUnsupported = platform.ErrUnsupported

ErrUnsupported is platform.ErrUnsupported, re-exported for callers outside the module.

Functions

func AllowSchemes

func AllowSchemes(s ...string)

AllowSchemes replaces the set of schemes OpenURL accepts, for the whole process. Schemes are case-insensitive, without the colon ("tel", "zoommtg"). With no arguments it restores DefaultSchemes. "file" is never allowed: use OpenPath.

func Allowed

func Allowed(rawURL string) bool

Allowed reports whether OpenURL would accept rawURL.

func OpenPath

func OpenPath(a *tango.App, path string) error

OpenPath opens a file with its default application, or a directory in the file manager.

func OpenURL

func OpenURL(a *tango.App, rawURL string) error

OpenURL opens rawURL with the system's handler for its scheme (the default browser for http and https, the mail app for mailto).

func RevealPath

func RevealPath(a *tango.App, path string) error

RevealPath shows path selected in its folder (Finder, Explorer, the file manager). Where the file manager cannot select items, its parent folder is opened.

Types

This section is empty.

Jump to

Keyboard shortcuts

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