Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateSHA256(path string) ([]byte, error)
- func CheckGO() bool
- func CheckWritable(path string) error
- func Chmod(path string, perm os.FileMode) error
- func Contains(array []string, str string) bool
- func Create(path string) (*os.File, error)
- func CreateTarZst(sourceDir, outputFile string, formatGNU bool) error
- func CreateWrite(path, data string) error
- func Download(destination, uri string) error
- func Exec(excludeStdout bool, dir, name string, args ...string) error
- func Exists(path string) bool
- func ExistsMakeDir(path string) error
- func Filename(path string) string
- func GOSetup() error
- func GetArchitecture() string
- func GetDirSize(path string) (int64, error)
- func GetFileType(path string) string
- func GitClone(dloadFilePath, sourceItemURI, sshPassword string, ...) error
- func IsEmptyDir(path string, dirEntry os.DirEntry) bool
- func IsStaticLibrary(path string) bool
- func Open(path string) (*os.File, error)
- func PullContainers(distro string) error
- func RunScript(cmds string) error
- func SetupCcache() error
- func StringifyArray(node *syntax.Assign) []string
- func StringifyAssign(node *syntax.Assign) string
- func StringifyFuncDecl(node *syntax.FuncDecl) string
- func StripFile(path string, args ...string) error
- func StripLTO(path string, args ...string) error
- func Unarchive(source, destination string) error
- type FileContent
- type FileInfo
- type OSRelease
Constants ¶
const ( // TagLink is a symbolic link file mode constant. TagLink = 0o120000 // TagDirectory is a directory file mode constant. TagDirectory = 0o40000 // TypeFile is the type of a regular file. This is also the type that is // implied when no type is specified. TypeFile = "file" // TypeDir is the type of a directory that is explicitly added in order to // declare ownership or non-standard permission. TypeDir = "dir" // TypeImplicitDir is the type of a directory that is implicitly added as a // parent of a file. TypeImplicitDir = "implicit dir" // TypeSymlink is the type of a symlink that is created at the destination // path and points to the source path. TypeSymlink = "symlink" // TypeTree is the type of a whole directory tree structure. TypeTree = "tree" // TypeConfig is the type of a configuration file that may be changed by the // user of the package. TypeConfig = "config" // TypeConfigNoReplace is like TypeConfig with an added noreplace directive // that is respected by RPM-based distributions. // For all other package formats it is handled exactly like TypeConfig. TypeConfigNoReplace = "config|noreplace" )
Variables ¶
var ( // Logger is the default logger with information level logging. // It writes to the MultiPrinter's writer. Logger = pterm.DefaultLogger.WithLevel(pterm.LogLevelInfo).WithWriter(MultiPrinter.Writer) // MultiPrinter is the default multi printer. MultiPrinter = pterm.DefaultMultiPrinter )
Functions ¶
func CalculateSHA256 ¶
CalculateSHA256 calculates the SHA-256 checksum of a file.
func CheckGO ¶
func CheckGO() bool
CheckGO checks if the GO executable is already installed.
It does not take any parameters. It returns a boolean value indicating whether the GO executable is already installed.
func CheckWritable ¶
CheckWritable checks if a binary file is writeable.
It checks if the file exists and if write permission is granted. If the file does not exist or does not have write permission, an error is returned.
func Chmod ¶
Chmod changes the file mode of the specified path.
It takes a string parameter `path` which represents the path of the file whose mode needs to be changed. It also takes an `os.FileMode` parameter `perm` which represents the new file mode to be set.
The function returns an error if there was an issue changing the file mode. If the file mode was successfully changed, it returns nil.
func Create ¶
Create creates a new file at the specified path.
It takes a string parameter `path` which represents the path of the file to be created. The function returns a pointer to an `os.File` and an error.
func CreateTarZst ¶
CreateTarZst creates a compressed tar.zst archive from the specified source directory. It takes the source directory and the output file path as arguments and returns an error if any occurs.
func CreateWrite ¶
CreateWrite writes the given data to the file specified by the path.
It takes two parameters: - path: a string representing the path of the file. - data: a string representing the data to be written to the file.
It returns an error if there was a problem creating or writing to the file.
func Download ¶
Download downloads a file from the given URL and saves it to the specified destination.
Parameters: - destination: the path where the downloaded file will be saved. - url: the URL of the file to download.
func Exec ¶
Exec executes a command in the specified directory.
It takes the following parameters: - dir: the directory in which the command will be executed. - name: the name of the command to be executed. - arg: optional arguments to be passed to the command.
It returns an error if the command execution fails.
func Exists ¶
Exists checks if a file or directory exists at the given path.
path: the path to the file or directory. bool: returns true if the file or directory exists, false otherwise.
func ExistsMakeDir ¶
ExistsMakeDir checks if a directory exists at the given path and creates it if it doesn't.
path: the path to the directory. error: returns an error if the directory cannot be created or accessed.
func Filename ¶
Filename returns the filename from a given path.
It takes a string parameter `path` which represents the path of the file. It returns a string which is the filename extracted from the path.
func GOSetup ¶
func GOSetup() error
GOSetup sets up the Go environment.
It checks if Go is installed and if not, it downloads and installs it. The function takes no parameters and does not return anything.
func GetArchitecture ¶
func GetArchitecture() string
GetArchitecture returns the corresponding pacman architecture for the current GOARCH.
func GetDirSize ¶
GetDirSize calculates the size of a directory in kilobytes.
It takes a path as a parameter and returns the size of the directory in bytes and an error if any.
func GetFileType ¶
GetFileType uses readelf to determine the type of the binary file.
func GitClone ¶
func GitClone(dloadFilePath, sourceItemURI, sshPassword string, referenceName plumbing.ReferenceName) error
GitClone clones a Git repository from the given sourceItemURI to the specified dloadFilePath.
Parameters: - sourceItemURI: the URI of the Git repository to clone. - dloadFilePath: the file path to clone the repository into. - sshPassword: the password for SSH authentication (optional). - referenceName: the reference name for the clone operation.
func IsEmptyDir ¶
IsEmptyDir checks if a directory is empty.
It takes in two parameters: path, a string representing the directory path, and dirEntry, an os.DirEntry representing the directory entry. It returns a boolean value indicating whether the directory is empty or not.
func IsStaticLibrary ¶
IsStaticLibrary checks if the binary is a static library.
func Open ¶
Open opens a file at the specified path and returns a pointer to the file and an error.
The path parameter is a string representing the file path to be opened. The function returns a pointer to an os.File and an error.
func PullContainers ¶
PullContainers pulls the specified container image.
distro: the name of the container image to pull. error: returns an error if the container image cannot be pulled.
func RunScript ¶
RunScript runs a shell script.
It takes a string parameter `cmds` which represents the shell script to be executed. The function returns an error if there was an issue running the script.
func SetupCcache ¶
func SetupCcache() error
SetupCcache checks if ccache is installed and configures environment variables.
It does not take any parameters. It returns an error if environment variable setup fails.
func StringifyArray ¶
StringifyArray generates a string representation of an array in the given syntax.
node: A pointer to the syntax.Assign node representing the array. []string: An array of strings representing the stringified elements of the array.
func StringifyAssign ¶
StringifyAssign returns a string representation of the given *syntax.Assign node.
It takes a pointer to a *syntax.Assign node as its parameter. It returns a string.
func StringifyFuncDecl ¶
StringifyFuncDecl converts a syntax.FuncDecl node to a string representation.
It takes a pointer to a syntax.FuncDecl node as a parameter and returns a string.