util

package
v3.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: BSD-2-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const MinCommitHashLength = 7

MinCommitHashLength is the Git default for a short SHA.

Variables

This section is empty.

Functions

func AskConfirm

func AskConfirm(ioReader io.Reader, question string) (bool, error)

AskConfirm asks the user for confirmation and returns true if yes.

func AtoiUint64

func AtoiUint64(str string) (uint64, error)

AtoiUint64 converts string to uint64.

func Bold

func Bold(s string) string

Bold makes the input string bold.

func CheckRecommendedBinaries

func CheckRecommendedBinaries(binaries ...string)

CheckRecommendedBinaries warns if some binaries not found in PATH.

func CollectWalFiles

func CollectWalFiles(paths []string, isRecursive bool) ([]string, error)

CollectWalFiles collects WAL (Write-Ahead Log) files based on the given set of paths. It identifies files with ".snap" or ".xlog" extensions as WAL files. For directory paths, it traverses them based on the isRecursive flag. It skips directories or files it cannot access due to permissions, logging warnings.

The function ensures that ".snap" files are sorted before ".xlog" files in the result, and that the returned list contains unique absolute paths.

Returns: A sorted, unique slice of strings containing the absolute paths of collected WAL files.

func CreateDirectory

func CreateDirectory(dirName string, fileMode os.FileMode) error

CreateDirectory create a directory with existence and error checks.

func ExtractTarGz

func ExtractTarGz(tarName, dstDir string) error

ExtractTarGz extracts tar.gz archive.

func FileLinesScanner

func FileLinesScanner(reader io.Reader) *bufio.Scanner

FileLinesScanner returns scanner for file.

func FileSHA256Hex

func FileSHA256Hex(path string) (string, error)

FileSHA256Hex computes SHA256 for a given file. The result is returned in a hex form.

func FindNamedMatches

func FindNamedMatches(pattern *regexp.Regexp, str string) map[string]string

FindNamedMatches processes regexp with named capture groups and transforms output to a map. If capture group is optional and was not found, map value is empty string.

func FsCopyFileChangePerms

func FsCopyFileChangePerms(fsys fs.FS, src, dst string, perms int) error

FsCopyFileChangePerms copies file from the certain FS with changing perms.

func GetFileContentBytes

func GetFileContentBytes(path string) ([]byte, error)

GetFileContentBytes returns file content as a bytes slice.

func GetHomeDir

func GetHomeDir() (string, error)

GetHomeDir returns current home directory.

func GetLastNLines

func GetLastNLines(filepath string, linesN int) ([]string, error)

GetLastNLines returns the last N lines from the file.

func GetLastNLinesBegin

func GetLastNLinesBegin(filepath string, lines int) (int64, error)

GetLastNLinesBegin return the position of last lines begin.

func GetTextTemplatedStr

func GetTextTemplatedStr(text *string, obj any) (string, error)

GetTextTemplatedStr returns the processed string text template.

func GetYamlFileName

func GetYamlFileName(fileName string, mustExist bool) (string, error)

GetYamlFileName searches for file with .yaml or .yml extension, based on the file name provided. If mustExist flag is set and no yaml files are found, ErrNotExists error is returned, passed fileName is returned otherwise.

func InternalError

func InternalError(format string, f VersionFunc, err ...any) error

InternalError shows error information, version of tt and call stack.

func IsDir

func IsDir(filePath string) bool

IsDir checks if filePath is a directory. Returns true if the directory exists.

func IsRegularFile

func IsRegularFile(filePath string) bool

IsRegularFile checks if filePath is a regular file. Returns true if the file exists and it is a regular file.

func IsValidCommitHash

func IsValidCommitHash(hash string) (bool, error)

IsValidCommitHash checks hash format.

func JoinAbspath

func JoinAbspath(paths ...string) (string, error)

JoinAbspath concat paths and makes the resulting path absolute.

func JoinPaths

func JoinPaths(paths ...string) string

JoinPaths concat paths.

func Max

func Max(x, y int) int

Max returns the maximum value.

func NewArgError

func NewArgError(text string) error

NewArgError creates and returns new argument error.

func ParseYAML

func ParseYAML(path string) (map[string]any, error)

ParseYAML parse yaml file at specified path.

func PrintFromStart

func PrintFromStart(file *os.File) error

func RunCommand

func RunCommand(cmd *exec.Cmd, workingDir string, showOutput bool) error

RunCommand runs specified command and returns an error. If showOutput is set to true, command output is shown. Else the output is kept aside, shown only if the command fails, and a spinner is shown on the log's terminal while the command runs.

func StringToTimestamp

func StringToTimestamp(input string) (string, error)

StringToTimestamp transforms string with number or RFC339Nano time to <sec.nanosecond> timestamp string.

Types

type ArgError

type ArgError struct {
	// contains filtered or unexported fields
}

ArgError represents command line arguments error.

func (ArgError) Error

func (e ArgError) Error() string

Error returns error message.

type VersionFunc

type VersionFunc func(bool, bool) string

VersionFunc is a type of function that return string with current Tarantool CLI version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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