common

package
v0.0.0-...-9976dbc Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

* @Date: 2022-04-30 10:34:56 * @LastEditTime: 2022-04-30 19:47:21 * @FilePath: \go-frame\pkgs\common\consts.go

* @Date: 2022-04-30 10:34:56 * @LastEditTime: 2022-05-01 22:29:19 * @FilePath: \go-frame\pkgs\common\utils.go

Index

Constants

View Source
const (
	DevMode  = "dev"
	TestMode = "test"
)
View Source
const (
	False = iota
	True
)
View Source
const (
	DefaultDb = "default"
)

默认的数据库连接名字

View Source
const (
	HttpCallTimeOut = time.Second * 5
)

http调用超时

View Source
const (
	RedisTimeout = time.Second * 5
)

Variables

View Source
var (
	Dev bool
)

Functions

func BytesToString

func BytesToString(b []byte) string

bytes转string

func GenID

func GenID() string

func GenNanoID

func GenNanoID() (string, error)

func GenZapNanoId

func GenZapNanoId() zapcore.Field

func InjectRedis

func InjectRedis(redisC redis.UniversalClient)

func Lock

func Lock(key string, options ...redsync.Option) (func() error, error)

func MustValidate

func MustValidate(a any)

数据验证,不通过直接panic

func ObjectMarshaler

func ObjectMarshaler(f func(zapcore.ObjectEncoder)) zapcore.ObjectMarshalerFunc

func Panic

func Panic(err error)

func StringToBytes

func StringToBytes(s string) []byte

string转byte

func TryGenNanoIDFromAlphaNumber

func TryGenNanoIDFromAlphaNumber(size, tryCount int, isValid func(id string) (bool, error)) (string, error)

size 表示生成的id长度, tryCount表示尝试次数,isValid验证生成的id是否有效

func Wrap

func Wrap(ctx *gin.Context) *ginContextWrapper

func ZapIntArray

func ZapIntArray(key string, data []int) zapcore.Field

func ZapStringArray

func ZapStringArray(key string, data []string) zapcore.Field

Types

This section is empty.

Jump to

Keyboard shortcuts

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