platform

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package platform provides OS-specific abstractions for cross-platform support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentArch

func CurrentArch() string

CurrentArch returns the current architecture.

func ExecutableExtension

func ExecutableExtension() string

ExecutableExtension returns the executable file extension for the current platform.

func HomeDirEnv

func HomeDirEnv() string

HomeDirEnv returns the environment variable name for the home directory.

func IsDarwin

func IsDarwin() bool

IsDarwin returns true if running on macOS.

func IsLinux

func IsLinux() bool

IsLinux returns true if running on Linux.

func IsWindows

func IsWindows() bool

IsWindows returns true if running on Windows.

func PathSeparator

func PathSeparator() string

PathSeparator returns the path separator for the current platform.

func Supports

func Supports(id ID) bool

Supports returns true if the given platform ID is supported.

func TempDir

func TempDir() string

TempDir returns the temp directory for the current platform.

Types

type DialogResult

type DialogResult int

DialogResult represents the result of a dialog interaction.

const (
	DialogResultCancel DialogResult = iota
	DialogResultUpdate
	DialogResultRemindLater
	DialogResultViewDetails
)

type ID

type ID string

ID represents a platform identifier.

const (
	Darwin  ID = "darwin"
	Linux   ID = "linux"
	Windows ID = "windows"
)

func CurrentID

func CurrentID() ID

CurrentID returns the current platform ID.

type Platform

type Platform interface {
	// Identity
	ID() ID
	Architecture() string
	Name() string

	// Paths
	GetDataDir() string
	GetConfigDir() string
	GetCacheDir() string
	GetLogDir() string
	GetIPCSocketPath() string

	// Auto-start
	EnableAutoStart(ctx context.Context) error
	DisableAutoStart(ctx context.Context) error
	IsAutoStartEnabled(ctx context.Context) (bool, error)

	// Executables
	FindExecutable(name string) (string, error)
	FindExecutables(name string) ([]string, error)
	IsExecutableInPath(name string) bool
	GetPathDirs() []string

	// Commands
	GetShell() string
	GetShellArg() string

	// Notifications
	ShowNotification(title, message string) error

	// Dialogs
	ShowChangelogDialog(agentName, fromVer, toVer, changelog string) DialogResult
}

Platform abstracts OS-specific operations.

func Current

func Current() Platform

Current returns the Platform implementation for the current OS.

Jump to

Keyboard shortcuts

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