utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte     = 1
	KiloByte = 1024 * Byte
	MegaByte = 1024 * KiloByte
	GigaByte = 1024 * MegaByte
	TeraByte = 1024 * GigaByte
)

Variables

This section is empty.

Functions

func Exists

func Exists(path string) bool

Exists checks whether some path exists or not.

func FatalCheck

func FatalCheck(err error)

FatalCheck prints & panics if there's an error.

func FilenameWithHash

func FilenameWithHash(url string) string

FilenameWithHash returns the hash-basename from the url.

func FilenameWithoutHash

func FilenameWithoutHash(url string) string

FilenameWithoutHash returns the basename of the url.

func FolderOf

func FolderOf(url string) string

FolderOf gets the folder of a download safely.

func HashOf

func HashOf(str string) string

HashOf returns the sha256 sum256 hash of the parameter.

func IsURL

func IsURL(URL string) bool

IsURL checks whether a url is valid or not.

func MakePartName

func MakePartName(part int64, parallelism int64) string

MakePartName creates the part name with the part number formatted with as many leading zeros as needed. For example, MakePartName(0, 100) = "part.00", MakePartName(100, 100) = "part.99" and MakePartName(101, 101) = "part.100".

func MkdirIfNotExist

func MkdirIfNotExist(folder string) error

MkdirIfNotExist makes a directory with perm 0700 if not exists.

func ReadableMemorySize

func ReadableMemorySize(bytes int64) string

ReadableMemorySize returns a prettier form of some memory size.

func ResolveURL

func ResolveURL(URL string) (string, error)

ResolveURL resolves the url adding the http scheme going for https-first if needed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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