platform

package
v1.1.57 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package platform provides cross-platform compatibility utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arch

func Arch() string

Arch returns the current architecture: "amd64", "arm64", "386", etc.

func CacheDir

func CacheDir() string

CacheDir returns the platform-specific cache directory.

func CommonPaths

func CommonPaths() map[string]string

CommonPaths returns platform-specific common system paths.

func ConfigDir

func ConfigDir() string

ConfigDir returns the platform-specific configuration directory.

func DataDir

func DataDir() string

DataDir returns the platform-specific data directory.

func DefaultEnvVars

func DefaultEnvVars() []string

DefaultEnvVars returns environment variables to pass through sandbox.

func DefaultShell

func DefaultShell() string

DefaultShell returns the default shell for the current platform.

func DeniedPaths

func DeniedPaths() []string

DeniedPaths returns paths that should be denied in sandbox mode.

func EnsureWindowsBusybox

func EnsureWindowsBusybox() error

EnsureWindowsBusybox is a no-op on non-Windows platforms.

func ExecutableExt

func ExecutableExt() string

ExecutableExt returns the platform-specific executable extension.

func ExpandHome

func ExpandHome(path string) string

ExpandHome expands ~ to the user's home directory.

func HomeDir

func HomeDir() string

HomeDir returns the user's home directory.

func Is64Bit

func Is64Bit() bool

Is64Bit returns true if the architecture is 64-bit.

func Is386

func Is386() bool

Is386 returns true if running on 32-bit x86.

func IsAIX

func IsAIX() bool

IsAIX returns true if running on AIX.

func IsAMD64

func IsAMD64() bool

IsAMD64 returns true if running on amd64 (x86-64).

func IsARM

func IsARM() bool

IsARM returns true if running on 32-bit ARM.

func IsARM64

func IsARM64() bool

IsARM64 returns true if running on arm64 (AArch64).

func IsBSD

func IsBSD() bool

IsBSD returns true if running on any BSD variant (FreeBSD, OpenBSD, NetBSD, DragonFly BSD).

func IsDragonflyBSD

func IsDragonflyBSD() bool

IsDragonflyBSD returns true if running on DragonFly BSD.

func IsExecutable

func IsExecutable(info os.FileMode) bool

IsExecutable checks if a file is executable on the current platform.

func IsFreeBSD

func IsFreeBSD() bool

IsFreeBSD returns true if running on FreeBSD.

func IsLinux

func IsLinux() bool

IsLinux returns true if running on Linux.

func IsLittleEndian

func IsLittleEndian() bool

IsLittleEndian returns true if the architecture is little-endian. Returns true for most modern architectures; false for s390x, ppc64 (BE), mips64 (BE).

func IsMacOS

func IsMacOS() bool

IsMacOS returns true if running on macOS.

func IsNetBSD

func IsNetBSD() bool

IsNetBSD returns true if running on NetBSD.

func IsOpenBSD

func IsOpenBSD() bool

IsOpenBSD returns true if running on OpenBSD.

func IsPlan9

func IsPlan9() bool

IsPlan9 returns true if running on Plan 9.

func IsSolaris

func IsSolaris() bool

IsSolaris returns true if running on Solaris or illumos.

func IsUnix

func IsUnix() bool

IsUnix returns true if running on a Unix-like OS (Linux, macOS, BSD, Solaris, illumos, AIX).

func IsWindows

func IsWindows() bool

IsWindows returns true if running on Windows.

func JoinPath

func JoinPath(elem ...string) string

JoinPath joins path elements using the platform-specific separator.

func NormalizePath

func NormalizePath(path string) string

NormalizePath normalizes a path for the current platform. Converts forward slashes to backslashes on Windows.

func OS

func OS() string

OS returns the current operating system: "windows", "darwin", "linux", etc.

func OpenFile

func OpenFile(path string) error

OpenFile opens path with the platform default application.

func PathSeparator

func PathSeparator() string

PathSeparator returns the platform-specific path separator.

func SandboxPaths

func SandboxPaths() []string

SandboxPaths returns paths that should be accessible in sandbox mode.

func SessionDir

func SessionDir() string

SessionDir returns the platform-specific session directory.

func ShellArgs

func ShellArgs(shell, command string) []string

ShellArgs returns the arguments to execute a command in the shell.

func SkillsDir

func SkillsDir() string

SkillsDir returns the platform-specific skills directory.

func TempDir

func TempDir() string

TempDir returns the platform-specific temp directory.

func WindowsBusyboxPath

func WindowsBusyboxPath() (string, bool)

WindowsBusyboxPath is unavailable on non-Windows platforms.

Types

This section is empty.

Jump to

Keyboard shortcuts

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