utils

package
v0.0.0-...-efab2a5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Chmod

func Chmod(path string, perm os.FileMode) error

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

func Create(path string) (*os.File, error)

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 CreateWrite

func CreateWrite(path, data string) error

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

func Download(destination, url string)

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

func Exec(dir, name string, arg ...string) error

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 ExecOutput

func ExecOutput(dir, name string, arg ...string) (string, error)

ExecOutput executes a command with the given arguments and returns its output as a string.

It takes the following parameters: - dir: the directory in which the command should be executed. - name: the name of the command to be executed. - arg: a variadic parameter representing the arguments to be passed to the command.

It returns a string representing the output of the command and an error if any occurred.

func Exists

func Exists(path string) bool

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

func ExistsMakeDir(path string) error

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

func Filename(path string) string

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()

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 GetDirSize

func GetDirSize(path string) (int64, error)

GetDirSize calculates the size of a directory in kilobytes.

It takes a path as a parameter and returns the size of the directory in kilobytes and an error if any.

func IsEmptyDir

func IsEmptyDir(path string, dirEntry os.DirEntry) bool

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 MkdirAll

func MkdirAll(path string) error

MkdirAll creates a directory and all its parent directories.

It takes a string parameter `path` which represents the path of the directory to be created. The function returns an error if any error occurs during the directory creation process.

func Open

func Open(path string) (*os.File, error)

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

func PullContainers(target string) error

PullContainers pulls the specified container image.

target: the name of the container image to pull. error: returns an error if the container image cannot be pulled.

func Remove

func Remove(path string) error

Remove deletes a file or directory at the specified path.

path: the path of the file or directory to be removed. Returns an error if the removal fails.

func RemoveAll

func RemoveAll(path string) error

RemoveAll removes a file or directory and any children it contains.

path: the path of the file or directory to be removed. error: an error if the removal fails.

func StringifyArray

func StringifyArray(node *syntax.Assign) []string

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

func StringifyAssign(node *syntax.Assign) string

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

func StringifyFuncDecl(node *syntax.FuncDecl) string

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.

func Unarchive

func Unarchive(archiveReader io.Reader, destination string) error

Unarchive extracts files from an archive and saves them to a destination directory.

archiveReader is an io.Reader that represents the archive file. destination is the path to the directory where the files will be saved. Returns an error if there was a problem extracting the files.

Types

This section is empty.

Jump to

Keyboard shortcuts

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