utils

package
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B = 1 << (iota * 10)
	KB
	MB
	GB
	TB
)

Variables

View Source
var (
	// ErrDownloadNotExist is an error thrown when trying to fetch an inexistent download.
	ErrDownloadNotExist = errors.New("download does not exist")

	// ErrDownloadBroken is an error thrown when trying to fetch a broken download.
	ErrDownloadBroken = errors.New("download is broken")

	// ErrFilenameEmpty is an error thrown when a cleaned download filename is empty.
	ErrFilenameEmpty = errors.New("filename is empty")

	// ErrFilenameTooLong is an error thrown when a download filename is too long.
	ErrFilenameTooLong = errors.New("filename is too long")
)
View Source
var HTTPClient = &http.Client{
	Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}},
}

Functions

func CheckFilenameValidity added in v1.0.0

func CheckFilenameValidity(filename string) error

CheckFilenameValidity checks if a filename is valid. If it is not, returns an error.

func ConsoleCancelableContext added in v1.0.0

func ConsoleCancelableContext() context.Context

ConsoleCancelableContext creates a context that can be canceled from the console. For example, by typing Ctrl + C.

func ReadableMemorySize

func ReadableMemorySize(bytes uint64) string

ReadableMemorySize returns a prettier form of some memory size expressed in bytes. Note: Do not exceed the float64 limit, as the result will overflow.

func ResolveURL

func ResolveURL(rawURL string) (string, error)

ResolveURL resolves the rawURL adding the http prefix, preferring https over http.

Types

This section is empty.

Jump to

Keyboard shortcuts

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