utils

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	B = 1 << (10 * iota)
	KB
	MB
	GB
	TB
)
View Source
const (
	Nanosecond  = 1
	Microsecond = 1000 * Nanosecond
	Millisecond = 1000 * Microsecond
	Second      = 1000 * Millisecond
	Minute      = 60 * Second
	Hour        = 60 * Minute
)

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(duration int64) string

func FormatSize

func FormatSize(size int64) string

func GenerateToken added in v0.0.8

func GenerateToken(size int) (string, error)

func Hash

func Hash(w io.Reader) ([]byte, error)

func ParseSize added in v0.0.2

func ParseSize(size string) int64

func SplitHash

func SplitHash(str string) (string, error)

func Stringify

func Stringify(v interface{}) string

Stringify beautify interface to string

func ValidDirectoryName

func ValidDirectoryName(name string) string

Types

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(tokenPreSecond int) *RateLimiter

func (*RateLimiter) Timing

func (r *RateLimiter) Timing()

Timing add token into semaphore

func (*RateLimiter) Token

func (r *RateLimiter) Token()

Jump to

Keyboard shortcuts

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