tools

package
v0.0.0-...-4e35581 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CodeSuccess ...
	CodeSuccess = 0
	// CodeFail ...
	CodeFail = 1
	// CodeUnknownError ...
	CodeUnknownError = -1
	// CodeSessionError ...
	CodeSessionError = 40000
)
View Source
const SessionPrefix = "sess_"

SessionPrefix ...

Variables

View Source
var MsgCodeMap = map[int]string{
	CodeUnknownError: "unKnow error",
	CodeSuccess:      "success",
	CodeFail:         "fail",
	CodeSessionError: "Session error",
}

MsgCodeMap ...

View Source
var RedisClientMap = map[string]*redis.Client{}

RedisClientMap ...

Functions

func CityHash32

func CityHash32(s []byte, length uint32) uint32

func CityHash64

func CityHash64(s []byte, length uint32) uint64

func CityHash64WithSeed

func CityHash64WithSeed(s []byte, length uint32, seed uint64) uint64

func CityHash64WithSeeds

func CityHash64WithSeeds(s []byte, length uint32, seed0, seed1 uint64) uint64

func CreateSessionID

func CreateSessionID(sessionID string) string

CreateSessionID ...

func FailWithMsg

func FailWithMsg(c *gin.Context, msg interface{})

FailWithMsg ...

func GetNowDateTime

func GetNowDateTime() string

GetNowDateTime ...

func GetRandomToken

func GetRandomToken(length int) string

GetRandomToken ...

func GetRedisInstance

func GetRedisInstance(redisOpt RedisOption) *redis.Client

GetRedisInstance ...

func GetSessionIDByUserID

func GetSessionIDByUserID(userID int) string

GetSessionIDByUserID ...

func GetSessionName

func GetSessionName(sessionID string) string

GetSessionName ...

func GetSnowflakeID

func GetSnowflakeID() string

GetSnowflakeID ...

func IsLittleEndian

func IsLittleEndian() bool

func ParseNetwork

func ParseNetwork(str string) (network, addr string, err error)

ParseNetwork ...

func ResponseWithCode

func ResponseWithCode(c *gin.Context, msgCode int, msg interface{}, data interface{})

ResponseWithCode ...

func Sha1

func Sha1(s string) (str string)

Sha1 ...

func SuccessWithMsg

func SuccessWithMsg(c *gin.Context, msg interface{}, data interface{})

SuccessWithMsg ...

Types

type RedisOption

type RedisOption struct {
	Address  string
	Password string
	Db       int
}

RedisOption ...

type Uint128

type Uint128 [2]uint64

func CityHash128

func CityHash128(s []byte, length uint32) (result Uint128)

func CityHash128WithSeed

func CityHash128WithSeed(s []byte, length uint32, seed Uint128) Uint128

func (Uint128) Bytes

func (this Uint128) Bytes() []byte

func (Uint128) Higher64

func (this Uint128) Higher64() uint64

func (Uint128) Lower64

func (this Uint128) Lower64() uint64

Jump to

Keyboard shortcuts

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