utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChineseLength

func ChineseLength(str string, limit int) int

func ChunkString

func ChunkString(s string, chunkSize int) []string

func HttpGetBytes

func HttpGetBytes(url, cookie string) ([]byte, error)

func HttpPostBytes

func HttpPostBytes(url string, data []byte) ([]byte, error)

func HttpPostBytesWithCookie

func HttpPostBytesWithCookie(url string, data []byte, cookie string, contentType ...string) ([]byte, error)

func IsChanClosed

func IsChanClosed(ch interface{}) bool

func RandomString

func RandomString(len int) string

func RandomStringRange

func RandomStringRange(len int, str string) string

func ToGroupCode

func ToGroupCode(groupUin int64) int64

func ToGroupUin

func ToGroupUin(groupCode int64) int64

Types

type Cache

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

Cache - simple implementation of cache More information: https://en.wikipedia.org/wiki/Time_to_live

func NewCache

func NewCache(interval time.Duration) *Cache

NewCache - initialization of new cache. For avoid mistake - minimal time to live is 1 minute. For simplification, - key is string and cache haven`t stop method

func (*Cache) Add

func (cache *Cache) Add(key string, value interface{}, ttl time.Duration)

Add - add key/value in cache

func (*Cache) Count

func (cache *Cache) Count() int

Count - return amount element of TTL map.

func (*Cache) Get

func (cache *Cache) Get(key string) (interface{}, bool)

Get - return value from cache

func (*Cache) GetKeys

func (cache *Cache) GetKeys() []interface{}

GetKeys - return all keys of cache map

Jump to

Keyboard shortcuts

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