platform

package
v1.45.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicCreateFile

func AtomicCreateFile(path string) (bool, error)

AtomicCreateFile creates a file atomically using O_EXCL flag Returns true if file was created, false if it already exists

func CleanupOldFiles

func CleanupOldFiles(dir, pattern string, maxAge int64) error

CleanupOldFiles removes files older than maxAge seconds matching a pattern

func CurrentTimestamp

func CurrentTimestamp() int64

CurrentTimestamp returns the current Unix timestamp

func ExpandEnv

func ExpandEnv(s string) string

ExpandEnv expands environment variables in a string (like ${VAR} or $VAR)

func FileAge

func FileAge(path string) int64

FileAge returns the age of a file in seconds Returns -1 if the file doesn't exist

func FileExists

func FileExists(path string) bool

FileExists checks if a file exists

func FileMTime

func FileMTime(path string) int64

FileMTime returns the modification time of a file as Unix timestamp Returns 0 if the file doesn't exist or on error

func GetGitBranch

func GetGitBranch(cwd string) string

GetGitBranch returns the current git branch name for the given directory. Returns empty string if not in a git repository or on error.

func IsLinux

func IsLinux() bool

IsLinux returns true if running on Linux

func IsMacOS

func IsMacOS() bool

IsMacOS returns true if running on macOS

func IsWindows

func IsWindows() bool

IsWindows returns true if running on Windows

func NormalizePath

func NormalizePath(path string) string

NormalizePath normalizes a file path (removes double slashes, etc.)

func OS

func OS() string

OS returns the current operating system

func SetDetachedProcAttr

func SetDetachedProcAttr(cmd *exec.Cmd)

SetDetachedProcAttr configures the command to run as a detached process on Unix. Setpgid creates a new process group so the child survives parent exit.

func TempDir

func TempDir() string

TempDir returns the platform-specific temporary directory (without trailing slash)

Types

type GitMetadata

type GitMetadata struct {
	Branch            string
	CommitHash        string
	CommitShortHash   string
	CommitAuthorName  string
	CommitAuthorEmail string
	UserName          string
	UserEmail         string
}

GitMetadata contains commonly requested git values for a working tree.

func GetGitMetadata

func GetGitMetadata(cwd string) GitMetadata

GetGitMetadata returns commonly used git metadata for the given directory. Empty fields indicate the directory is not a git repo or the value is unavailable.

Jump to

Keyboard shortcuts

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