util

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HttpProtocol  = []byte("http://")
	HttpsProtocol = []byte("https://")
)

Functions

func AppendPaddingUint added in v0.0.2

func AppendPaddingUint(dst []byte, n, p int, c byte) []byte

AppendPaddingUint appends n with c padding that size of p to dst and returns the extended dst.

func AppendQueryString

func AppendQueryString(dst, qstr []byte) []byte

AppendQueryString appends qstr to dst.

func AppendSpacePaddingUint added in v0.0.2

func AppendSpacePaddingUint(dst []byte, n, p int) []byte

AppendSpacePaddingUint appends n with space padding that size of p to dst and returns the extended dst.

func AppendZeroPaddingUint

func AppendZeroPaddingUint(dst []byte, n, p int) []byte

AppendZeroPaddingUint appends n with zero padding that size of p to dst and returns the extended dst.

func Bytes2dEqual added in v0.3.6

func Bytes2dEqual(a, b [][]byte) bool

Bytes2dEqual reports whether a and b are the same length and contain the same two dimensional (2d) bytes.

func CopyPaddingRightUint added in v0.3.4

func CopyPaddingRightUint(dst []byte, n, p int, c byte) (offset int)

CopyPaddingRightUint copies n with c padding that size of p to the right side of dst, and returns coppied offset of dst.

func CopyRightUint added in v0.3.4

func CopyRightUint(dst []byte, n int) (offset int)

CopyRightUint copies n to the right side of dst.

func IsHttpOrHttps

func IsHttpOrHttps(uri []byte) bool

func IsHttpStatusRedirect

func IsHttpStatusRedirect(status int) bool

func SplitRequestURI

func SplitRequestURI(uri []byte) ([]byte, []byte)

SplitRequestURI splits path and query string.

Types

type Cache

type Cache interface {
	Get(key CacheKey) interface{}
	Set(key CacheKey, value interface{})
	Del(key CacheKey)
	Len() int
	// OnRelease sets a callback that will be called on the key is released.
	OnRelease(cb func(key CacheKey, value interface{}))
}

Cache is an interface that defines accessor of the cache.

func NewExpireCache

func NewExpireCache(expire int64) Cache

NewExpireCache returns a new cache with the specified expire (ms) and default interval 1 min.

func NewExpireCacheInterval

func NewExpireCacheInterval(expire, interval int64) Cache

NewExpireCacheInterval returns a new cache with the specified expire (ms) and interval (ms).

type CacheKey added in v0.3.4

type CacheKey uint64

func CacheKeyBytes added in v0.3.4

func CacheKeyBytes(bs ...[]byte) CacheKey

func CacheKeyString added in v0.3.4

func CacheKeyString(ss ...string) CacheKey

type Strftime added in v0.0.2

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

Strftime is a strftime formatter.

func NewStrftime added in v0.0.2

func NewStrftime(format string) *Strftime

NewStrftime creates a new Strftime.

func NewStrftimeBytes added in v0.0.2

func NewStrftimeBytes(format []byte) *Strftime

NewStrftimeBytes creates a new Strftime.

func (*Strftime) AppendBytes added in v0.0.2

func (s *Strftime) AppendBytes(dst []byte, t time.Time) []byte

AppendBytes appends format result to dst and returns the extended buffer.

func (*Strftime) Format added in v0.0.2

func (s *Strftime) Format(t time.Time) string

Format formats the specified time.

func (*Strftime) FormatBytes added in v0.0.2

func (s *Strftime) FormatBytes(t time.Time) []byte

FormatBytes formats the specified time.

type StringList added in v0.3.6

type StringList []string

StringList is an array of strings that implements flag.Value.

func (*StringList) Set added in v0.3.6

func (ss *StringList) Set(value string) error

func (*StringList) String added in v0.3.6

func (ss *StringList) String() string

type StringSet added in v0.3.6

type StringSet []string

StringSet is an array of strings that can be duplicated via Append.

func (StringSet) Append added in v0.3.6

func (ss StringSet) Append(values ...string) StringSet

Append appends values to the StringSet without duplication.

Jump to

Keyboard shortcuts

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