commons

package
v0.11.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BYTE = 1 << (10 * iota)
	KILOBYTE
	MEGABYTE
	GIGABYTE
	TERABYTE
	PETABYTE
	EXABYTE
)

Variables

This section is empty.

Functions

func ByteSize added in v0.4.0

func ByteSize(bytes uint64) string

ByteSize returns a human-readable byte string of the form 10M, 12.5K, and so forth. The following units are available:

E: Exabyte
P: Petabyte
T: Terabyte
G: Gigabyte
M: Megabyte
K: Kilobyte
B: Byte

The unit that results in the smallest number greater than or equal to 1 is always chosen.

func IpFromHostname

func IpFromHostname(enableIpV6 bool) (ip string, err error)

IpFromHostname 通过host获取ip列表中的第一个

func ParseTime

func ParseTime(value string) (result time.Time, err error)

func ToBytes added in v0.4.0

func ToBytes(s string) (uint64, error)

ToBytes parses a string formatted by ByteSize as bytes. Note binary-prefixed and SI prefixed units both mean a base-2 units KB = K = KiB = 1024 MB = M = MiB = 1024 * K GB = G = GiB = 1024 * M TB = T = TiB = 1024 * G PB = P = PiB = 1024 * T EB = E = EiB = 1024 * P

func ToMegabytes added in v0.4.0

func ToMegabytes(s string) (uint64, error)

ToMegabytes parses a string formatted by ByteSize as megabytes.

func ValidateFieldMessage

func ValidateFieldMessage(_type reflect.Type, exp string) (key string, msg string)

func ValidateRegisterDefault added in v0.3.3

func ValidateRegisterDefault(validate *validator.Validate)

func ValidateRegisterNotBlank added in v0.3.2

func ValidateRegisterNotBlank(validate *validator.Validate)

func ValidateRegisterNotEmpty added in v0.3.2

func ValidateRegisterNotEmpty(validate *validator.Validate)

func ValidateRegisterRegex

func ValidateRegisterRegex(validate *validator.Validate)

Types

type Keyable added in v0.1.1

type Keyable interface {
	Key() (key string)
}

type Ring added in v0.1.1

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

func NewRing added in v0.1.1

func NewRing(values ...Keyable) (r *Ring)

func (*Ring) Append added in v0.1.1

func (r *Ring) Append(v Keyable)

func (*Ring) Next added in v0.1.1

func (r *Ring) Next() (value Keyable)

func (*Ring) Remove added in v0.1.1

func (r *Ring) Remove(v Keyable)

func (*Ring) Size added in v0.1.1

func (r *Ring) Size() (size int)

func (*Ring) String added in v0.1.1

func (r *Ring) String() (value string)

type RingEntry added in v0.1.1

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

type Wildcard

type Wildcard struct {
	Prefix string
	Suffix string
}

func (Wildcard) Match

func (w Wildcard) Match(s string) bool

Jump to

Keyboard shortcuts

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