utils

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RedColor    = "\033[31m"
	YellowColor = "\033[33m"
	BlueColor   = "\033[34m"
	ResetColor  = "\033[0m"
)

ANSI escape codes for color

Variables

View Source
var (
	Spinner *yacspin.Spinner
)

global spinner

Functions

func BoolValue added in v0.2.2

func BoolValue(b *bool) bool

boolValue safely dereferences a bool pointer, returning false if nil

func Confirm added in v0.1.7

func Confirm(msg string) bool

func DownloadAndExtract added in v0.2.4

func DownloadAndExtract(url, dest, targetName string, giveExec bool) error

DownloadAndExtract downloads an archive from url, extracts it to dest. If targetName is specified, only that file is kept (others are removed). If giveExec is true, execute permissions are added to the target file. The archive is cleaned up after extraction.

func DownloadUrl added in v0.2.0

func DownloadUrl(url, dest string) error

downloads a file from a url and places it in a specified destination

func ExtractArchive added in v0.2.4

func ExtractArchive(src, dest string) error

ExtractArchive auto-detects the archive format and extracts it.

func ExtractBinary added in v0.2.4

func ExtractBinary(src, dest, binaryName string) error

ExtractBinary extracts an archive and gives execute permissions to the specified binary.

func ExtractBz2 added in v0.2.4

func ExtractBz2(src, dest string) error

ExtractBz2 extracts a .tar.bz2 archive to the destination directory.

func ExtractSingleFile added in v0.2.4

func ExtractSingleFile(archivePath, destPath, targetName string) error

ExtractSingleFile extracts a single file from an archive to destPath. It searches for a file matching targetName anywhere in the archive.

func ExtractTgz added in v0.2.4

func ExtractTgz(src, dest string) error

ExtractTgz extracts a .tar.gz or .tgz archive to the destination directory.

func ExtractZip added in v0.2.4

func ExtractZip(src, dest string) error

ExtractZip extracts a zip archive to the destination directory.

func FindBinary added in v0.2.2

func FindBinary(binaryNames map[string]string, destFolder string) (string, error)

FindBinary checks that the binary exists in dest or $PATH, preferring $PATH. Checks that binary also has executable permissions.

func FormatErrors added in v0.1.6

func FormatErrors(errs []error) string

Formats a slice of errors to a single error, each seperated by a new line

func FormatFileSize added in v0.2.4

func FormatFileSize(bytes int64) string

FormatFileSize formats bytes into human-readable format (KB, MB, GB).

func GetFileExtensionFromURL added in v0.1.7

func GetFileExtensionFromURL(rawurl string) (string, error)

func GetRemoteFileSize added in v0.2.4

func GetRemoteFileSize(url string) string

GetRemoteFileSize returns the size of a remote file in a human-readable format. Returns empty string if size cannot be determined.

func GiveExecutePerms added in v0.2.4

func GiveExecutePerms(path string) error

GiveExecutePerms adds execute permissions to a file.

func HandleError added in v0.1.6

func HandleError(err error, msg ...string)

Prints the error in red and exits

func NewSpinner added in v0.2.2

func NewSpinner(cfg yacspin.Config)

Creates a new global spinner

func OpenURL added in v0.1.7

func OpenURL(url string) error

opens a URL in your default browser of your operating system

func SetSpinnerQuiet added in v0.2.2

func SetSpinnerQuiet(quiet bool)

Sets the spinner to quiet mode by discarding all output to not interfere with Unix pipes or redirections

func SpinnerConfig added in v0.2.2

func SpinnerConfig() yacspin.Config

Types

This section is empty.

Jump to

Keyboard shortcuts

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