golibs

package module
v1.2024.116 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 46 Imported by: 13

README

#golibs

go通用库

Documentation

Index

Constants

View Source
const (
	Time_TIMEyyyyMMdd           string = "20060102"
	Time_TIMEyyyy_MM_dd         string = "2006-01-02"
	Time_TIMEStandard           string = "2006-01-02 15:04:05"
	Time_TIME_HH_mm_ss          string = "15:04:05"
	Time_TIMEMSSQL              string = "2006-01-02T15:04:05.000Z"
	Time_TIMEMYSQL              string = "2006-01-02T15:04:05+08:00"
	Time_TIMEyyyyMMddHHmmss     string = "20060102150405"
	Time_TIMEyyyyMMddHHmmssffff string = "200601021504059999"
	Time_TIMEJavaUtilDate       string = "20060102150405000-0700"
	Time_TIMEISO8601            string = "2006-01-02T15:04:05.000-0700"
)
View Source
const ENTRY_HDR_SIZE = 24
View Source
const HASH_ENTRY_SIZE = 16
View Source
const VERSION = "v1.2024.116"

Variables

View Source
var (
	// Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC
	// You may customize this to set a different epoch for your application.
	Epoch int64 = 1288834974657

	// Number of bits to use for Node
	// Remember, you have a total 22 bits to share between Node/Step
	NodeBits uint8 = 10

	// Number of bits to use for Step
	// Remember, you have a total 22 bits to share between Node/Step
	StepBits uint8 = 12
)
View Source
var (
	GetFileSuffixRegex         = regexp.MustCompile(".(jpg|jpeg|png|gif|exe|doc|docx|ppt|pptx|xls|xlsx)")
	IsTaobaoNickRegex          = regexp.MustCompile(`(^[\\u4e00-\\u9fa5\\w_—\\-,。…·〔〕()!@¥%……&*?、;‘“]*$)`)
	IsSubTaobaoNickRegex       = regexp.MustCompile(`(^[\\u4e00-\\u9fa5\\w_—\\-,。…·〔〕()!@¥%……&*?、;‘“:]*$)`)
	IsVersionRegex             = regexp.MustCompile(`(^[0-9.]*$)`)
	IsUrlRegex                 = regexp.MustCompile(`(^[a-zA-z]+://[^\s]*$)`)
	IsNumberRegex              = regexp.MustCompile(`(^[0-9]*$)`)
	IsAsciiRegex               = regexp.MustCompile(`(^[\x00-\xff]*$)`)
	IsMultipNumberRegex        = regexp.MustCompile(`(^[0-9,]*$)`)
	IsLetterOrNumberRegex      = regexp.MustCompile(`(^[A-Za-z0-9_]*$)`)
	IsLetterOrNumber1Regex     = regexp.MustCompile(`(^[A-Za-z0-9_-]*$)`)
	IsHanOrLetterOrNumberRegex = regexp.MustCompile("^[A-Za-z0-9_\u4e00-\u9fa5-]*$")
	IsGeneralStringRegex       = regexp.MustCompile("^[A-Za-z0-9_\\-#+./:\u4e00-\u9fa5]*$")
	IsStandardTimeRegex        = regexp.MustCompile(`^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$`)
	IsIPAddressRegecx          = regexp.MustCompile(`^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$`)
	IsIntranetIPRegex          = regexp.MustCompile(`^(127\.0\.0\.1)|(10\.\d{1,3}\.\d{1,3}\.\d{1,3})|(172\.((1[6-9])|(2\d)|(3[01]))\.\d{1,3}\.\d{1,3})|(192\.168\.\d{1,3}\.\d{1,3})$`)
	IsEmailRegex               = regexp.MustCompile(`^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$`)
	IsMobileRegex              = regexp.MustCompile(`^1[3456789]\d{9}$`)
)
View Source
var ErrInvalidBase32 = errors.New("invalid base32")

ErrInvalidBase32 is returned by ParseBase32 when given an invalid []byte

View Source
var ErrInvalidBase58 = errors.New("invalid base58")

ErrInvalidBase58 is returned by ParseBase58 when given an invalid []byte

View Source
var ErrLargeEntry = errors.New("The entry size is larger than 1/1024 of cache size")
View Source
var ErrLargeKey = errors.New("The key is larger than 65535")
View Source
var ErrNotFound = errors.New("Entry not found")
View Source
var ErrOutOfRange = errors.New("out of range")

Functions

func AesDecrypt

func AesDecrypt(crypted, key, iv []byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(plaintext, key, iv []byte) ([]byte, error)

func ApiSign

func ApiSign(params url.Values, secret string) string

api签名,用于开放平台

func ApiSignIsValid

func ApiSignIsValid(params url.Values, secret string) bool

api签名,用于开放平台

func Base64

func Base64(src []byte) string

func BcryptEncrypt

func BcryptEncrypt(message []byte) ([]byte, error)

func BuildRequestUrl

func BuildRequestUrl(requestUrl string, params url.Values) string

获取url和参数列表对应的完整请求url

func ByteToGByte

func ByteToGByte(byte_value float64) string

func BytesToUInt

func BytesToUInt(b []byte) uint32

字节转换成整形

func CacheCount

func CacheCount() int

func CacheDel

func CacheDel(key string)

func CacheGetBool

func CacheGetBool(key string) (value bool, ok bool)

func CacheGetByteArray

func CacheGetByteArray(key string) (value []byte, ok bool)

func CacheGetInt

func CacheGetInt(key string) (value int, ok bool)

func CacheGetInt64

func CacheGetInt64(key string) (value int64, ok bool)

func CacheGetString

func CacheGetString(key string) (value string, ok bool)

func CacheGetTime

func CacheGetTime(key string) (value time.Time, ok bool)

func CacheSet

func CacheSet(key string, value interface{})

func CheckBcrypt

func CheckBcrypt(hashBytes, s []byte) (bool, error)

func ConfusedTwo

func ConfusedTwo(sourceBytes []byte) []byte

混淆[]byte

func CreateMultiDir

func CreateMultiDir(filePath string) error

CreateMultiDir 调用os.MkdirAll递归创建文件夹

func DesDecrypt

func DesDecrypt(crypted, key, iv []byte) ([]byte, error)

func DesEncrypt

func DesEncrypt(origData, key, iv []byte) ([]byte, error)

func FormatJson

func FormatJson(data interface{}) string

格式化为Json字符串

func From2000Nano

func From2000Nano() int64

返回从2000-01-01 00:00:00到现在经过的纳秒数

func GenUUID32

func GenUUID32() string

func GenUUID36

func GenUUID36() string

func GenUniqueId

func GenUniqueId() string

获取一个唯一id

func GenerateSign

func GenerateSign(params map[string]string, secret string, taobao_nick string, time int64) string

func GenerateSignNoUser

func GenerateSignNoUser(params map[string]string, secret string) string

func Get

func Get(requestUrl string) (int, string, error)

获取url对应的内容,返回信息:StatusCode,body,err

func GetByAuthToken

func GetByAuthToken(requestUrl, authToken string) (int, string, error)

带上AuthToken,发起一个get请求

func GetByToken

func GetByToken(requestUrl, token string) (int, string, error)

带上Bearer Token,发起一个get请求

func GetCRC32

func GetCRC32(s string) uint32

func GetCurrentDirectory

func GetCurrentDirectory() string

获取程序运行路径

func GetCurrentIntranetIP

func GetCurrentIntranetIP() string

获取当前内网IP

func GetDate

func GetDate(t time.Time) int

获取当前日期

func GetFileSuffix

func GetFileSuffix(s string) string

获取文件扩展名

func GetGuid

func GetGuid() string

获取一个Guid

func GetIPAddressNotPort

func GetIPAddressNotPort(ip_address string) string

获取IP地址,不包含端口号

func GetIPNums

func GetIPNums(s string) (ipNum uint32, err error)

把IP地址转成数字

func GetPwd

func GetPwd(lenth int) string

生成随机密码,短时间内会重复

func GetSimplePwd

func GetSimplePwd(lenth int) string

生成简单随机密码,短时间内会重复

func GetTimeInt64

func GetTimeInt64() int64

获取当前时间的int64格式,yyyyMMddHHmmss

func HTMLEncode

func HTMLEncode(s string) string

html编码

func HexStringToBytes

func HexStringToBytes(hex_str string) []byte

把十六进制字符串转成字节数组

func HmacMd5

func HmacMd5(message, secret []byte) []byte

func HmacSha1

func HmacSha1(message, secret []byte) []byte

func HmacSha256

func HmacSha256(message, secret []byte) []byte

func HmacSha512

func HmacSha512(message, secret []byte) []byte

func HomePath

func HomePath() (string, error)

HomePath 获取当前用户根目录

func IsAllChineseChar

func IsAllChineseChar(s string) bool

判断字符串是否全中文字符

func IsAscii

func IsAscii(s string) bool

是否Ascii字符

func IsEmail

func IsEmail(s string) bool

是否email

func IsGeneralString

func IsGeneralString(s string) bool

判断是否由汉字、字母、数字、下划线、中杠等组成

func IsHanOrLetterOrNumber

func IsHanOrLetterOrNumber(s string) bool

判断是否由汉字、字母、数字、下划线组成

func IsIPAddress

func IsIPAddress(s string) bool

是否IPv4地址

func IsIntranetIP

func IsIntranetIP(s string) bool

是否内网IP地址

func IsLetterOrNumber

func IsLetterOrNumber(s string) bool

判断是否由字母、数字、下划线组成

func IsLetterOrNumber1

func IsLetterOrNumber1(s string) bool

判断是否由字母、数字、下划线组成

func IsMobile

func IsMobile(s string) bool

是否手机号

func IsMultipNumber

func IsMultipNumber(s string) bool

是否多数字(用逗号间隔)

func IsNumber

func IsNumber(s string) bool

是否数字

func IsStandardTime

func IsStandardTime(s string) bool

判断是否标准时间格式

func IsSubTaobaoNick

func IsSubTaobaoNick(s string) bool

判断是否是淘宝用户名(子帐号)

func IsTaobaoNick

func IsTaobaoNick(s string) bool

判断是否是淘宝用户名

func IsUrl

func IsUrl(s string) bool

判断是否网址

func IsUtf8

func IsUtf8(s string) bool

是否utf-8编码字符串

func IsVersion

func IsVersion(s string) bool

判断是否版本号

func Length

func Length(str string) int

使用 utf8.RuneCountInString()统计字符串长度

func Md5

func Md5(s string) string

func Method

func Method(r *http.Request) string

获取当前连接的Http方法

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

func PKCS7Unpadding

func PKCS7Unpadding(origData []byte) []byte

func ParseRequestQuery

func ParseRequestQuery(req string) (params url.Values, err error)

解析请求参数到一个url.Values对象

func Post

func Post(requestUrl string, params url.Values) (int, string, error)

获取url对应的内容,返回信息:StatusCode,body,err

func PostBody

func PostBody(requestUrl string, reqBody string) (int, string, error)

用Post方法获取url对应的内容,提交body,返回信息:StatusCode,body,err

func PostByAuthToken

func PostByAuthToken(requestUrl string, authToken string, params url.Values) (int, string, error)

获取url对应的内容,返回信息:StatusCode,body,err

func PostByToken

func PostByToken(requestUrl, token string) (int, string, error)

带上Bearer Token,发起一个post请求,无内容

func PostFile

func PostFile(requestUrl string, params url.Values, field_name, path string) (int, string, error)

获取url对应的内容,同时上传文件,返回信息:StatusCode,body,err

func PostJson

func PostJson(requestUrl string, params map[string]string) (int, string, error)

用Post方法获取url对应的内容,提交json,返回信息:StatusCode,body,err

func PostJsonByToken

func PostJsonByToken(requestUrl, token, jsonString string) (int, string, error)

带上Bearer Token,发起一个post请求,内容是json

func RandInt64

func RandInt64(min, max int64) int64

生成指定范围内的int64数字

func RemoveDuplicateStrings

func RemoveDuplicateStrings(strs []string) []string

RemoveDuplicateStrings 字符串切片去重

func ReversalBytes

func ReversalBytes(source []byte) []byte

反转[]byte

func ReverseString

func ReverseString(s string) string

字符串逆序

func Sha1

func Sha1(message []byte) []byte

func Sha256

func Sha256(bs []byte) []byte

func Sha512

func Sha512(bs []byte) []byte

func Since

func Since(t time.Time) int64

Since返回从t到现在经过的毫秒数

func Sleep

func Sleep(t time.Time, delay int64)

延时delay毫秒,从t开始计时

func SliceByteToString

func SliceByteToString(b []byte) string

string()

func StandardTime

func StandardTime() string

返回当前时间字符串

func Strim

func Strim(s string) string

删除空格、换行、空格等字符

func String2Unicode

func String2Unicode(s string) string

字符串转成Unicode编码

func StringToSliceByte

func StringToSliceByte(s string) []byte

[]byte()

func SubString

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

字串截取

func TimeStringToTime

func TimeStringToTime(sourceTime string) (time.Time, error)

把时间字符串转成本地时间

func ToConfusedBase64

func ToConfusedBase64(str string) string

混淆-->base64

func ToConfusedZipBase64

func ToConfusedZipBase64(str string) string

混淆-->zlib压缩-->base64

func ToJson

func ToJson(data interface{}) string

序列化为json

func ToJsonConfusedBase64

func ToJsonConfusedBase64(obj interface{}) string

序列化-->混淆-->base64

func ToJsonZipConfusedBase64

func ToJsonZipConfusedBase64(obj interface{}) string

序列化-->zlib压缩-->混淆-->base64

func TopSign

func TopSign(params url.Values, secret string) string

func UIntToBytes

func UIntToBytes(value uint32) []byte

整形转换成字节

func UnBase64

func UnBase64(source string) ([]byte, error)

func UnConfusedTwo

func UnConfusedTwo(confusedBytes []byte) []byte

反混淆[]byte

func UnZipMd5

func UnZipMd5(zip_string string) (md5_string string, err error)

解压缩汉字,结果为guid或md5值

func Unicode2String

func Unicode2String(s string) (to string, err error)

Unicode编码转成字符串

func Unix

func Unix() int64

返回当前时间戳(秒)

func UnixMilliSecond

func UnixMilliSecond() int64

返回当前时间戳(毫秒)

func UnixNano

func UnixNano() int64

返回当前时间戳(纳秒)

func UrlDecode

func UrlDecode(source string) (string, error)

func UrlEncode

func UrlEncode(source string) string

func Version2Time

func Version2Time(version string) (t time.Time, err error)

版本号转时间,格式:2019.905.1052

func ZipMd5

func ZipMd5(md5String string) (zip_string string, err error)

压缩md5或guid

func ZlibUnzipBytes

func ZlibUnzipBytes(input []byte) ([]byte, error)

func ZlibZipBytes

func ZlibZipBytes(input []byte) ([]byte, error)

Types

type Cache

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

Cache is a freecache instance.

func NewCache

func NewCache(size int) (cache *Cache)

NewCache returns a newly initialize cache by size. The cache size will be set to 512KB at minimum. If the size is set relatively large, you should call `debug.SetGCPercent()`, set it to a much smaller value to limit the memory consumption and GC pause time.

func NewCacheCustomTimer

func NewCacheCustomTimer(size int, timer Timer) (cache *Cache)

NewCacheCustomTimer returns new cache with custom timer.

func (*Cache) AverageAccessTime

func (cache *Cache) AverageAccessTime() int64

AverageAccessTime returns the average unix timestamp when a entry being accessed. Entries have greater access time will be evacuated when it is about to be overwritten by new value.

func (*Cache) Clear

func (cache *Cache) Clear()

Clear clears the cache.

func (*Cache) Del

func (cache *Cache) Del(key []byte) (affected bool)

Del deletes an item in the cache by key and returns true or false if a delete occurred.

func (*Cache) DelInt

func (cache *Cache) DelInt(key int64) (affected bool)

DelInt deletes an item in the cache by int key and returns true or false if a delete occurred.

func (*Cache) EntryCount

func (cache *Cache) EntryCount() (entryCount int64)

EntryCount returns the number of items currently in the cache.

func (*Cache) EvacuateCount

func (cache *Cache) EvacuateCount() (count int64)

EvacuateCount is a metric indicating the number of times an eviction occurred.

func (*Cache) ExpiredCount

func (cache *Cache) ExpiredCount() (count int64)

ExpiredCount is a metric indicating the number of times an expire occurred.

func (*Cache) Get

func (cache *Cache) Get(key []byte) (value []byte, err error)

Get returns the value or not found error.

func (*Cache) GetInt

func (cache *Cache) GetInt(key int64) (value []byte, err error)

GetInt returns the value for an integer within the cache or a not found error.

func (*Cache) GetIntWithExpiration

func (cache *Cache) GetIntWithExpiration(key int64) (value []byte, expireAt uint32, err error)

GetIntWithExpiration returns the value and expiration or a not found error.

func (*Cache) GetOrSet

func (cache *Cache) GetOrSet(key, value []byte, expireSeconds int) (retValue []byte, err error)

GetOrSet returns existing value or if record doesn't exist it sets a new key, value and expiration for a cache entry and stores it in the cache, returns nil in that case

func (*Cache) GetWithBuf

func (cache *Cache) GetWithBuf(key, buf []byte) (value []byte, err error)

GetWithBuf copies the value to the buf or returns not found error. This method doesn't allocate memory when the capacity of buf is greater or equal to value.

func (*Cache) GetWithExpiration

func (cache *Cache) GetWithExpiration(key []byte) (value []byte, expireAt uint32, err error)

GetWithExpiration returns the value with expiration or not found error.

func (*Cache) HitCount

func (cache *Cache) HitCount() (count int64)

HitCount is a metric that returns number of times a key was found in the cache.

func (*Cache) HitRate

func (cache *Cache) HitRate() float64

HitRate is the ratio of hits over lookups.

func (*Cache) Incr

func (cache *Cache) Incr(key []byte, expireSeconds int) (value int64, err error)

Incr command increments the numeric value stored in the key by one

func (*Cache) LookupCount

func (cache *Cache) LookupCount() int64

LookupCount is a metric that returns the number of times a lookup for a given key occurred.

func (*Cache) MissCount

func (cache *Cache) MissCount() (count int64)

MissCount is a metric that returns the number of times a miss occurred in the cache.

func (*Cache) NewIterator

func (cache *Cache) NewIterator() *Iterator

NewIterator creates a new iterator for the cache.

func (*Cache) OverwriteCount

func (cache *Cache) OverwriteCount() (overwriteCount int64)

OverwriteCount indicates the number of times entries have been overriden.

func (*Cache) Peek

func (cache *Cache) Peek(key []byte) (value []byte, err error)

Peek returns the value or not found error, without updating access time or counters.

func (*Cache) ResetStatistics

func (cache *Cache) ResetStatistics()

ResetStatistics refreshes the current state of the statistics.

func (*Cache) Set

func (cache *Cache) Set(key, value []byte, expireSeconds int) (err error)

Set sets a key, value and expiration for a cache entry and stores it in the cache. If the key is larger than 65535 or value is larger than 1/1024 of the cache size, the entry will not be written to the cache. expireSeconds <= 0 means no expire, but it can be evicted when cache is full.

func (*Cache) SetInt

func (cache *Cache) SetInt(key int64, value []byte, expireSeconds int) (err error)

SetInt stores in integer value in the cache.

func (*Cache) TTL

func (cache *Cache) TTL(key []byte) (timeLeft uint32, err error)

TTL returns the TTL time left for a given key or a not found error.

func (*Cache) Touch

func (cache *Cache) Touch(key []byte, expireSeconds int) (err error)

Touch updates the expiration time of an existing key. expireSeconds <= 0 means no expire, but it can be evicted when cache is full.

func (*Cache) TouchedCount

func (cache *Cache) TouchedCount() (touchedCount int64)

TouchedCount indicates the number of times entries have had their expiration time extended.

type Entry

type Entry struct {
	Key   []byte
	Value []byte
}

Entry represents a key/value pair.

type ID

type ID int64

An ID is a custom type used for a snowflake ID. This is used so we can attach methods onto the ID.

func ParseBase32

func ParseBase32(b []byte) (ID, error)

ParseBase32 parses a base32 []byte into a snowflake ID NOTE: There are many different base32 implementations so becareful when doing any interoperation interop with other packages.

func ParseBase58

func ParseBase58(b []byte) (ID, error)

ParseBase58 parses a base58 []byte into a snowflake ID

func (ID) Base2

func (f ID) Base2() string

Base2 returns a string base2 of the snowflake ID

func (ID) Base32

func (f ID) Base32() string

Base32 uses the z-base-32 character set but encodes and decodes similar to base58, allowing it to create an even smaller result string. NOTE: There are many different base32 implementations so becareful when doing any interoperation interop with other packages.

func (ID) Base36

func (f ID) Base36() string

Base36 returns a base36 string of the snowflake ID

func (ID) Base58

func (f ID) Base58() string

Base58 returns a base58 string of the snowflake ID

func (ID) Base64

func (f ID) Base64() string

Base64 returns a base64 string of the snowflake ID

func (ID) Bytes

func (f ID) Bytes() []byte

Bytes returns a byte slice of the snowflake ID

func (ID) Int64

func (f ID) Int64() int64

Int64 returns an int64 of the snowflake ID

func (ID) IntBytes

func (f ID) IntBytes() [8]byte

IntBytes returns an array of bytes of the snowflake ID, encoded as a big endian integer.

func (ID) MarshalJSON

func (f ID) MarshalJSON() ([]byte, error)

MarshalJSON returns a json byte array string of the snowflake ID.

func (ID) Node

func (f ID) Node() int64

Node returns an int64 of the snowflake ID node number

func (ID) Step

func (f ID) Step() int64

Step returns an int64 of the snowflake step (or sequence) number

func (ID) String

func (f ID) String() string

String returns a string of the snowflake ID

func (ID) Time

func (f ID) Time() int64

Time returns an int64 unix timestamp of the snowflake ID time

func (*ID) UnmarshalJSON

func (f *ID) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a json byte array of a snowflake ID into an ID type.

type Iterator

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

Iterator iterates the entries for the cache.

func (*Iterator) Next

func (it *Iterator) Next() *Entry

Next returns the next entry for the iterator. The order of the entries is not guaranteed. If there is no more entries to return, nil will be returned.

type JSONSyntaxError

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

A JSONSyntaxError is returned from UnmarshalJSON if an invalid ID is provided.

func (JSONSyntaxError) Error

func (j JSONSyntaxError) Error() string

type LimitWaitGroup

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

func NewLimitWaitGroup

func NewLimitWaitGroup(limit int) *LimitWaitGroup

func (*LimitWaitGroup) Add

func (s *LimitWaitGroup) Add() error

func (*LimitWaitGroup) AddWithContext

func (s *LimitWaitGroup) AddWithContext(ctx context.Context) error

func (*LimitWaitGroup) Done

func (s *LimitWaitGroup) Done()

func (*LimitWaitGroup) Wait

func (s *LimitWaitGroup) Wait()

type Node

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

A Node struct holds the basic information needed for a snowflake generator node

func NewNode

func NewNode(node int64) (*Node, error)

NewNode returns a new snowflake node that can be used to generate snowflake IDs

func (*Node) Generate

func (n *Node) Generate() ID

Generate creates and returns a unique snowflake ID

func (*Node) GetTime

func (n *Node) GetTime(i int64) time.Time

type RingBuf

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

Ring buffer has a fixed size, when data exceeds the size, old data will be overwritten by new data. It only contains the data in the stream from begin to end

func NewRingBuf

func NewRingBuf(size int, begin int64) (rb RingBuf)

func (*RingBuf) Begin

func (rb *RingBuf) Begin() int64

func (*RingBuf) Dump

func (rb *RingBuf) Dump() []byte

Create a copy of the buffer.

func (*RingBuf) End

func (rb *RingBuf) End() int64

func (*RingBuf) EqualAt

func (rb *RingBuf) EqualAt(p []byte, off int64) bool

func (*RingBuf) Evacuate

func (rb *RingBuf) Evacuate(off int64, length int) (newOff int64)

Evacuate read the data at off, then write it to the the data stream, Keep it from being overwritten by new data.

func (*RingBuf) ReadAt

func (rb *RingBuf) ReadAt(p []byte, off int64) (n int, err error)

read up to len(p), at off of the data stream.

func (*RingBuf) Resize

func (rb *RingBuf) Resize(newSize int)

func (*RingBuf) Size

func (rb *RingBuf) Size() int64

func (*RingBuf) Skip

func (rb *RingBuf) Skip(length int64)

func (*RingBuf) String

func (rb *RingBuf) String() string

func (*RingBuf) Write

func (rb *RingBuf) Write(p []byte) (n int, err error)

func (*RingBuf) WriteAt

func (rb *RingBuf) WriteAt(p []byte, off int64) (n int, err error)

type StringBuilder

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

func NewStringBuilder

func NewStringBuilder() *StringBuilder

func (*StringBuilder) Append

func (this *StringBuilder) Append(obj interface{}) *StringBuilder

func (*StringBuilder) ToString

func (this *StringBuilder) ToString() string

type Timer

type Timer interface {
	// Give current time (in seconds)
	Now() uint32
}

timer holds representation of current time.

Directories

Path Synopsis
gbtree
B+ Tree
B+ Tree
gchan
优雅的Channel操作.
优雅的Channel操作.
glist
并发安全的双向链表.
并发安全的双向链表.
gmap
并发安全的哈希MAP.
并发安全的哈希MAP.
gqueue
并发安全的动态队列.
并发安全的动态队列.
gset
并发安全的集合SET.
并发安全的集合SET.
Goroutine池.
Goroutine池.
时间管理
时间管理
gconv
类型转换.
类型转换.
gidgen
ID生成器.
ID生成器.
grand
随机数管理
随机数管理
gregx
正则表达式
正则表达式
gutil
其他工具包
其他工具包

Jump to

Keyboard shortcuts

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