platform

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLoginItem

func IsLoginItem() bool

func Notify

func Notify(title, message string) error

Notify shows a best-effort native error message to the user. It exists for failures the user must see even though no window opened, such as opening a file outside the home directory. The error is returned so callers can fall back to logging when no native mechanism is available.

func OnOpenFile

func OnOpenFile(cb func(string))

OnOpenFile is a no-op on platforms where the OS delivers opened file paths via argv (Linux, Windows); those are handled through the normal argv + single- instance forwarding path.

func RealPath added in v1.2.0

func RealPath(f *os.File) (string, error)

RealPath returns the canonical filesystem path of the file the descriptor f actually points at, asked of the OS by handle rather than derived from the pathname used to open it. Because it reads through the open descriptor, a concurrent rename or symlink swap of the pathname cannot change the answer: it always names where the held inode really lives. Callers use it to enforce "never serve internal state" against the descriptor they hold, which closes the check-vs-open TOCTOU that any later pathname re-resolution leaves open. It fails closed (returns an error) on platforms without a native handle-to-path call.

func SelectFolder added in v1.2.0

func SelectFolder(prompt string) (path string, ok bool, err error)

SelectFolder shows a native folder-picker dialog and returns the chosen path. ok is false when the user cancels, which is a normal outcome rather than an error. On an unsupported platform it returns an error. The returned path is whatever the OS picker yields; the caller canonicalizes and validates it before trusting it.

func SetLoginItem

func SetLoginItem(enabled bool, executablePath string) error

Types

type ConfirmChoice added in v1.2.0

type ConfirmChoice int

ConfirmChoice is the outcome of a native permission dialog.

const (
	// ConfirmDeny is also the fail-closed default: any error, timeout, or
	// unsupported platform resolves to Deny so access is never granted by accident.
	ConfirmDeny ConfirmChoice = iota
	ConfirmAllowOnce
	// ConfirmTrustFolder is the durable choice: allow this read AND remember the
	// folder as trusted, so files opened from inside it stop asking. Platforms with
	// no clean third button degrade it to ConfirmAllowOnce, which errs toward less
	// permission rather than more.
	ConfirmTrustFolder
)

func Confirm added in v1.2.0

func Confirm(title, message string) (ConfirmChoice, error)

Confirm shows a modal, foreground native dialog for a permission grant and returns the user's choice. It is always a real OS dialog, never page content, so a served page cannot spoof, style, obscure, or auto-confirm it. On any error or unsupported platform it fails closed to ConfirmDeny.

func (ConfirmChoice) String added in v1.2.0

func (c ConfirmChoice) String() string

type SingleInstance

type SingleInstance interface {
	TryLock() (bool, error)
	SendFilePath(path string) error
	OnFileReceived(callback func(path string))
	Unlock() error
}

func NewSingleInstance

func NewSingleInstance(configDir string) SingleInstance

Jump to

Keyboard shortcuts

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