utils

package module
v0.0.0-...-23d4cfa Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KiB // 1024
	MiB // 1048576
	GiB // 1073741824
	TiB // 1099511627776             (超过了int32的范围)
	PiB // 1125899906842624
	EiB // 1152921504606846976
	ZiB // 1180591620717411303424    (超过了int64的范围)
	YiB // 1208925819614629174706176
)
View Source
const (
	HTTPStringFormat = "" /* 137-byte string literal not displayed */
)

Variables

View Source
var DefaultIdPool = NewRoomIdPool()
View Source
var MemCache = &cache{sm: make(map[string][]byte), mu: new(sync.Mutex)}

Functions

func Add

func Add(a, b float64) float64

a + b

func Base64StrDecode

func Base64StrDecode(in string) ([]byte, error)

func Base64StrEncode

func Base64StrEncode(in string) string

func Base64UrlSaveDecode

func Base64UrlSaveDecode(in string) ([]byte, error)

func Base64UrlSaveEncode

func Base64UrlSaveEncode(in string) string

func CmdAcceptor

func CmdAcceptor(fm map[string]func())

func DelSliceInt

func DelSliceInt(list []int, i int) []int

DelSliceInt DelSliceInt

func DelSliceInt32

func DelSliceInt32(list []int32, i int32) []int32

DelSliceInt32 DelSliceInt32

func DelSliceInt64

func DelSliceInt64(list []int64, i int64) []int64

DelSliceInt64 DelSliceInt64

func Div

func Div(a, b float64) float64

a / b

func GetHTTPRequest

func GetHTTPRequest(req []byte) (httpReq *http.Request, err error)

func GetLocalIP

func GetLocalIP() string

func GetPoker

func GetPoker() []int32

func GetPokerWithJoker

func GetPokerWithJoker() []int32

func GoroutineID

func GoroutineID() string

GoroutineID 获取其id

func IF

func IF(assert bool, a, b interface{}) interface{}

func IsMemberFloat64

func IsMemberFloat64(element float64, list []float64) bool

func IsMemberInt

func IsMemberInt(element int, list []int) bool

func IsMemberInt32

func IsMemberInt32(element int32, list []int32) bool

func IsMemberInt64

func IsMemberInt64(element int64, list []int64) bool

func MaxInt

func MaxInt(i ...int) int

func MaxInt32

func MaxInt32(i ...int32) int32

func MaxInt64

func MaxInt64(i ...int64) int64

func Md5Byte

func Md5Byte(in []byte) []byte

func Md5Str

func Md5Str(in ...interface{}) string

func Md5String

func Md5String(in string) string

func MemStat

func MemStat() uint64

MemStat 获取没存占用

func MinInt

func MinInt(i ...int) int

func MinInt32

func MinInt32(i ...int32) int32

func MinInt64

func MinInt64(i ...int64) int64

func Mul

func Mul(a, b float64) float64

a * b

func NewRawHTTPResponse

func NewRawHTTPResponse(status int, contentType string, body []byte) []byte

func NewRoomIdPool

func NewRoomIdPool() *roomIdPool

func Pack

func Pack(data [][]byte) []byte

func PackOne

func PackOne(data []byte) []byte

func RandTake

func RandTake(n int, src []int32, r *rand.Rand) (val, left []int32)

func ReversePokers

func ReversePokers(l [][]int32)

func Sha1Byte

func Sha1Byte(in []byte) []byte

func Sha1String

func Sha1String(in string) string

func Sha256

func Sha256(in string) []byte

func Stack

func Stack(skip int) []byte

Stack returns a nicely formatted stack frame, skipping skip frames.

func Str

func Str(v interface{}) string

Str Str

func Sub

func Sub(a, b float64) float64

a - b

func Take

func Take(src []int32, t ...int32) (left []int32, ok bool)

func ToFloat64

func ToFloat64(in string) (float64, error)

string ToFloat64 Float64

func UnixMs

func UnixMs() int64

Types

type AES

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

func NewAES

func NewAES(key, iv []byte) *AES

func (*AES) Decrypt

func (a *AES) Decrypt(src string) (strDesc string, err error)

解密字符串

func (*AES) Encrypt

func (a *AES) Encrypt(in string) (string, error)

加密字符串

Jump to

Keyboard shortcuts

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