utils

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BufferPool = &sync.Pool{
	New: func() interface{} {
		b := make([]byte, 4096)
		return &b
	},
}

Define a buffer pool globally to reuse buffers

Functions

func FormatFileSize

func FormatFileSize(bytes int64) string

func FormatPercentage

func FormatPercentage(current, total int64) string

func FormatSpeed

func FormatSpeed(bytes int64, totalMilliseconds int64) string

Types

type ProgressWriter

type ProgressWriter struct {
	Bar *uiprogress.Bar
	W   io.Writer
}

func (*ProgressWriter) Write

func (pw *ProgressWriter) Write(p []byte) (int, error)

type Utils

type Utils struct {
	PartsDir string
	Log      logger.LoggerInterface
}

func NewUtils

func NewUtils(partsDir string, log logger.LoggerInterface) *Utils

func (*Utils) ExtractTimestampFromFilename

func (u *Utils) ExtractTimestampFromFilename(filename string) (int64, error)

func (*Utils) GenerateTimestamp

func (u *Utils) GenerateTimestamp() int64
func (u *Utils) ParseLink(link string) (string, string, string, error)

ParseLink parses the given link and returns the resource name, query key, and query value.

func (*Utils) SanitizePath

func (u *Utils) SanitizePath(path string) string

func (*Utils) SetLogger

func (u *Utils) SetLogger(log logger.LoggerInterface)

func (*Utils) TrimLeadingSymbols

func (u *Utils) TrimLeadingSymbols(s string) string

func (*Utils) ZeroMemory

func (u *Utils) ZeroMemory(data []byte)

Method to zero out the memory of a byte slice, to prevent the sensitive data from lingering in memory

Jump to

Keyboard shortcuts

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