utils

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MinuteSeconds seconds of one minute
	MinuteSeconds = 60
	// HourSeconds seconds of one hour
	HourSeconds = 60 * MinuteSeconds
	// DaySeconds seconds of one day
	DaySeconds = 24 * HourSeconds
	// KBytes size of k
	KBytes = 1024
	// MBytes size of m
	MBytes = 1024 * KBytes
	// GBytes size of g
	GBytes = 1024 * MBytes

	// ErrTimeParse time parse error
	ErrTimeParse = errors.New("time parse error")
	// ErrSizeParse size parse error
	ErrSizeParse = errors.New("file size parse error")
)

Functions

func CalculateBlocks

func CalculateBlocks(totalSize, blockSize int) (blocks int)

func GetFirstMatchedString

func GetFirstMatchedString(re *regexp.Regexp, source string) (string, bool)

func LastSubstring

func LastSubstring(s string, sep string) string

func ParseSeconds

func ParseSeconds(interval string) (int, error)

ParseSeconds from 1h 10m 10d

func ParseSize

func ParseSize(fileSize string) (int, error)

ParseSize parse the file size

func ShortSourceLoc

func ShortSourceLoc(skip int) (fileName string, line int, funcName string, ok bool)

func SourceLoc

func SourceLoc(skip int) (file string, line int, funcName string, ok bool)

func TrimBytes

func TrimBytes(bs []byte) []byte

func ZipCompress

func ZipCompress(sourceFile, archiveFile string) error

Types

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(rate, intervalMillis int64) *RateLimiter

func (*RateLimiter) Allowable

func (rl *RateLimiter) Allowable() bool

Jump to

Keyboard shortcuts

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