utils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateFileMD5

func CalculateFileMD5(filename string) (string, error)

CalculateFileMD5 calculates MD5 hash of file

func CalculateSpeed

func CalculateSpeed(bytes int64, duration time.Duration) string

CalculateSpeed calculates transfer speed

func CreateFileWithDirs

func CreateFileWithDirs(filename string) (*os.File, error)

CreateFileWithDirs creates file, create directories if they don't exist

func EnsureDir

func EnsureDir(dir string) error

EnsureDir ensures directory exists, create if it doesn't exist

func FileExists

func FileExists(filename string) bool

FileExists checks if file exists

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes formats bytes to human readable format

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats time duration

func GetFileSize

func GetFileSize(filename string) (int64, error)

GetFileSize gets file size

func SanitizeFilename

func SanitizeFilename(filename string) string

SanitizeFilename cleans filename, removes unsafe characters

Types

type ProgressBar

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

ProgressBar progress bar structure

func NewProgressBar

func NewProgressBar(total int64, width int) *ProgressBar

NewProgressBar creates new progress bar

func (*ProgressBar) ETAString

func (p *ProgressBar) ETAString() string

ETAString gets estimated remaining time

func (*ProgressBar) GetPercent

func (p *ProgressBar) GetPercent() float64

GetPercent gets percentage

func (*ProgressBar) IsComplete

func (p *ProgressBar) IsComplete() bool

IsComplete checks if complete

func (*ProgressBar) String

func (p *ProgressBar) String() string

String returns string representation of progress bar

func (*ProgressBar) Update

func (p *ProgressBar) Update(current int64)

Update updates progress

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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