tools

package
v0.0.0-...-5e1d9b1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

*

  • Created by lock
  • Date: 2019-08-18
  • Time: 18:03

*

  • Created by lock
  • Date: 2019-08-12
  • Time: 16:00

*

  • Created by lock
  • Date: 2019-08-12
  • Time: 14:18

*

  • Created by lock
  • Date: 2019-10-06
  • Time: 23:30

Index

Constants

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

Variables

View Source
var MsgCodeMap = map[int]string{
	CodeUnknownError: "unknown error",
	CodeSuccess:      "success",
	CodeFail:         "fail",
	CodeSessionError: "session error",
}
View Source
var RedisClientMap = map[string]*redis.Client{}

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

func FailWithMsg

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

func GetNowDateTime

func GetNowDateTime() string

func GetRandomToken

func GetRandomToken(length int) string

func GetRedisInstance

func GetRedisInstance(redisOpt RedisOption) *redis.Client

func GetSessionIdByUserId

func GetSessionIdByUserId(userId int) string

func GetSessionName

func GetSessionName(sessionId string) string

func GetSnowflakeId

func GetSnowflakeId(nodeIDs ...int64) string

func IsLittleEndian

func IsLittleEndian() bool

func ParseNetwork

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

func ResponseWithCode

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

func Sha1

func Sha1(s string) (str string)

func SuccessWithMsg

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

Types

type RedisOption

type RedisOption struct {
	Address  string
	Password string
	Db       int
}

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