utils

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChecksumValidationFailed = errors.New("file sign validation error")
	ErrCouldNotOpenFile         = errors.New("opening source file")
	ErrCouldNotReadFile         = errors.New("reading source file content")
)

Functions

func AbsolutePath

func AbsolutePath(path string) (string, error)

AbsolutePath returns the absolute path

func DownloadFile

func DownloadFile(ctx context.Context, timeout time.Duration, u, destFile string) error

DownloadFile downloads a file

func ExpandPath

func ExpandPath(path string) (string, error)

ExpandPath expands tilde '~' character for home

func GetFileName

func GetFileName(u string) string

GetFileName returns file name from URL

func HTTPClient

func HTTPClient(t time.Duration) http.Client

HTTPClient returns a new HTTP client

func Must

func Must[T any](obj T, err error) T

func PackFiles

func PackFiles(ctx context.Context, src, dest string) error

func PasswordPrompt

func PasswordPrompt() (string, error)

PasswordPrompt prompts user for a password (hiding it's value from console)

func ShaHash

func ShaHash(r io.Reader) (string, error)

ShaHash calculates hash from io.Reader content

func Unpack added in v0.0.6

func Unpack(_ context.Context, instancePath, backupFile string) error

func UnpackTarGZ

func UnpackTarGZ(ctx context.Context, file, destDir string) error

UnpackTarGZ unpacks .tar.gz file to destDir

func ValidateFileIntegrity

func ValidateFileIntegrity(ctx context.Context, file, signature string) error

ValidateFileIntegrity validates down

func WarnOnError

func WarnOnError[T any](obj T, err error) T

Types

This section is empty.

Jump to

Keyboard shortcuts

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