util

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte  = 1
	KByte = Byte * 1024
	MByte = KByte * 1024
	GByte = MByte * 1024
	TByte = GByte * 1024
	PByte = TByte * 1024
	EByte = PByte * 1024
)
View Source
const (
	Minute = 60
	Hour   = 60 * Minute
	Day    = 24 * Hour
	Week   = 7 * Day
	Month  = 30 * Day
	Year   = 12 * Month
)

Seconds-based time units

Variables

This section is empty.

Functions

func AorB

func AorB(condition bool, a, b string) string

func ByteCountIEC

func ByteCountIEC(b int) string

func CompareVersion

func CompareVersion(src, toCompare string) bool

func CompressedHTML

func CompressedHTML(h *template.HTML)

func CopyMap

func CopyMap(m map[string]string) map[string]string

func DownloadTo

func DownloadTo(url, output string) error

func FileExist

func FileExist(path string) bool

func FileSize

func FileSize(s uint64) string

FileSize calculates the file size and generate user-friendly string.

func GetParentDirectory

func GetParentDirectory(directory string) string

func InArray

func InArray(arr []string, str string) bool

func IsDirectory

func IsDirectory(filename string) bool

func IsFile

func IsFile(filename string) bool

func IsHiddenFile

func IsHiddenFile(name string) bool

func IsJSON

func IsJSON(str string) bool

func JSON

func JSON(a interface{}) string

func MkFileIfNotExist

func MkFileIfNotExist(path string)

func MkdirIfNotExist

func MkdirIfNotExist(path string)

func NormalizeEOL

func NormalizeEOL(input []byte) []byte

NormalizeEOL will convert Windows (CRLF) and Mac (CR) EOLs to UNIX (LF)

func PackageName

func PackageName(v interface{}) string

func ParseBool

func ParseBool(s string) bool

func ParseFileContentType

func ParseFileContentType(fileName string) string

func ParseFloat32

func ParseFloat32(f string) float32

func ParseHTML

func ParseHTML(name, tmpl string, param interface{}) template.HTML

func ParseText

func ParseText(name, tmpl string, param interface{}) string

func ParseTime

func ParseTime(stringTime string) time.Time

func Random

func Random(strings []string) ([]string, error)

func ReplaceAll

func ReplaceAll(s string, oldnew ...string) string

func ReplaceNth

func ReplaceNth(s, old, new string, n int) string

func SetDefault

func SetDefault(value, condition, def string) string

func Substr

func Substr(s string, pos, length int) string

func TimeSincePro

func TimeSincePro(then time.Time, m map[string]string) string

TimeSincePro calculates the time interval and generate full user-friendly string.

func UnzipDir

func UnzipDir(src, dest string) error

func UploadFileTo

func UploadFileTo(fh *multipart.FileHeader, destDirectory string) (int64, error)

func Uuid

func Uuid(length int64) string

func WrapURL

func WrapURL(u string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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