sys

package
v0.4.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

Sep is the OS path separator as a string.

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(filePath string) (*os.File, error)

CreateFile opens or creates the file at filePath for reading and writing, creating parent directories as needed.

func DetectGitDefaultBranch

func DetectGitDefaultBranch(url string) string

DetectGitDefaultBranch queries the remote at url to find its default branch without cloning. Returns an empty string if the remote is unreachable or the branch cannot be determined.

func Expand

func Expand(input string) string

Expand expands environment variables in input without tokenizing, preserving quoting and spacing. Use ExpandPath for file system paths that also need ~ expansion.

func ExpandPath

func ExpandPath(input string) string

ExpandPath expands environment variables and a leading ~ in the given path.

func FileExists

func FileExists(path string) bool

FileExists reports whether the file or directory at path exists. Permission errors are treated as the path existing to avoid silently overwriting or recreating inaccessible files.

func GetHomeDir

func GetHomeDir() string

GetHomeDir returns the current user's home directory, fatally logging on failure.

func LatestGitHubPreRelease

func LatestGitHubPreRelease(repo string) string

LatestGitHubPreRelease returns the latest pre-release version for the given repo. Returns an empty string if none is found or the request fails.

func LatestGitHubRelease

func LatestGitHubRelease(repo string) string

LatestGitHubRelease queries the GitHub releases API for the given repo (e.g. "owner/repo") and returns the latest stable version without the leading "v". Returns an empty string if the request fails, times out, or no release exists.

func ReadLine

func ReadLine(reader *bufio.Reader, prompt string) string

ReadLine prints prompt to stdout and returns the trimmed line read from reader.

func ReadYesNo

func ReadYesNo(reader *bufio.Reader, prompt string) bool

ReadYesNo prompts the user and returns true if they answer "y" or "yes" (case-insensitive).

func SplitInput

func SplitInput(input string) []string

SplitInput splits a command string into tokens, respecting double-quoted segments. todo: replace with a proper shell-quoting parser

func ValidateFileName

func ValidateFileName(name string) error

ValidateFileName reports whether name is safe to use as a filename across common operating systems. It rejects empty names, path separators, shell special characters, control characters, and names composed only of dots or spaces.

func Yellow

func Yellow(s string) string

Yellow wraps s in yellow ANSI color codes.

Types

type Platform

type Platform string

Platform identifies the host operating system.

const (
	Windows Platform = "windows"
	Linux   Platform = "linux"
	Darwin  Platform = "darwin"
	Other   Platform = "other"
)

func GetPlatform

func GetPlatform() Platform

GetPlatform returns the current operating system as a Platform value.

Jump to

Keyboard shortcuts

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