utils

package module
v0.0.0-...-c6f6300 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2018 License: Apache-2.0 Imports: 13 Imported by: 7

README

utils GoDoc

Utils library for APIBox

See full document at: https://go-apibox.github.io/docs/#!other/utils.md (Chinese)

Documentation

Index

Constants

View Source
const (
	Byte = 1 << (iota * 10)
	KiByte
	MiByte
	GiByte
	TiByte
	PiByte
	EiByte
)

IEC Sizes. kibis of bits

View Source
const (
	IByte = 1
	KByte = IByte * 1000
	MByte = KByte * 1000
	GByte = MByte * 1000
	TByte = GByte * 1000
	PByte = TByte * 1000
	EByte = PByte * 1000
)

SI Sizes.

Variables

This section is empty.

Functions

func AbsPath

func AbsPath(path string) string

func Bytes

func Bytes(s uint64) string

Bytes produces a human readable representation of an SI size.

See also: ParseBytes.

Bytes(82854982) -> 83MB

func CamelCase

func CamelCase(str string) string

func Combine

func Combine(key string, val interface{}) map[string]interface{}

func CopyDir

func CopyDir(source string, dest string) (err error)

func CopyFile

func CopyFile(source string, dest string) (err error)

func FileExists

func FileExists(path string) bool

FileExists checks whether a file or directory exists.

func HBytes

func HBytes(s uint64) string

HBytes produces a short human readable representation of an IEC size.

See also: ParseBytes.

HBytes(82854982) -> 79M

func IBytes

func IBytes(s uint64) string

IBytes produces a human readable representation of an IEC size.

See also: ParseBytes.

IBytes(82854982) -> 79MiB

func IsPrivateIp

func IsPrivateIp(ip string) bool

func ParseBytes

func ParseBytes(s string) (uint64, error)

ParseBytes parses a string representation of bytes into the number of bytes it represents.

See Also: Bytes, IBytes.

ParseBytes("42MB") -> 42000000, nil ParseBytes("42mib") -> 44040192, nil

func RandAlphaString

func RandAlphaString() string

func RandAlphaStringN

func RandAlphaStringN(n int) string

func RandDatePrefixUint64

func RandDatePrefixUint64() uint64

func RandDigitString

func RandDigitString() string

func RandDigitStringN

func RandDigitStringN(n int) string

func RandString

func RandString() string

func RandStringN

func RandStringN(n int) string

func RandUint

func RandUint() uint

func RandUint32

func RandUint32() uint32

func RandUint32In

func RandUint32In(low, hi uint32) uint32

func RandUint64

func RandUint64() uint64

func RandUint64In

func RandUint64In(low, hi uint64) uint64

func RandUintIn

func RandUintIn(low, hi uint) uint

func SnakeCase

func SnakeCase(str string) string

func Timestamp

func Timestamp() uint32

Types

type Matcher

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

func NewMatcher

func NewMatcher() *Matcher

func (*Matcher) AddBlackItem

func (m *Matcher) AddBlackItem(item string) *Matcher

func (*Matcher) AddWhiteItem

func (m *Matcher) AddWhiteItem(item string) *Matcher

func (*Matcher) DelBlackItem

func (m *Matcher) DelBlackItem(item string) *Matcher

func (*Matcher) DelWhiteItem

func (m *Matcher) DelWhiteItem(item string) *Matcher

func (*Matcher) Match

func (m *Matcher) Match(target string) bool

func (*Matcher) SetBlackList

func (m *Matcher) SetBlackList(blackList []string) *Matcher

func (*Matcher) SetWhiteList

func (m *Matcher) SetWhiteList(whiteList []string) *Matcher

Jump to

Keyboard shortcuts

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