pkg

package
v0.0.0-...-3030a97 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TextBlack = iota + 30
	TextRed
	TextGreen
	TextYellow
	TextBlue
	TextMagenta
	TextCyan
	TextWhite
)
View Source
const (
	TrafficKey = "X-Request-Id"
	LoggerKey  = "_go-admin-logger-request"
)

Variables

This section is empty.

Functions

func Assert

func Assert(condition bool, msg string, code ...int)

Assert 条件断言 当断言条件为 假 时触发 panic 对于当前请求不会再执行接下来的代码,并且返回指定格式的错误信息和错误码

func Black

func Black(msg string) string

func Blue

func Blue(msg string) string

func CompareHashAndPassword

func CompareHashAndPassword(e string, p string) (bool, error)

func Cyan

func Cyan(msg string) string

func GenerateMsgIDFromContext

func GenerateMsgIDFromContext(c *gin.Context) string

GenerateMsgIDFromContext 生成msgID

func GenerateRandomKey

func GenerateRandomKey(length int) string

GenerateRandomKey 生成随机字符串

func GetCurrentTime

func GetCurrentTime() time.Time

func GetCurrentTimeStr

func GetCurrentTimeStr() string

func GetLocaHonst

func GetLocaHonst() string

获取局域网ip地址

func GetLocation

func GetLocation(ip, key string) string

获取外网ip地址

func GetOrm

func GetOrm(c *gin.Context) (*gorm.DB, error)

GetOrm 获取orm连接

func Green

func Green(msg string) string

func HasError

func HasError(err error, msg string, code ...int)

HasError 错误断言 当 error 不为 nil 时触发 panic 对于当前请求不会再执行接下来的代码,并且返回指定格式的错误信息和错误码 若 msg 为空,则默认为 error 中的内容

func Int64ToString

func Int64ToString(e int64) string

func IntToString

func IntToString(e int) string

func Magenta

func Magenta(msg string) string

func Red

func Red(msg string) string

func Round

func Round(f float64, n int) float64

func SetColor

func SetColor(msg string, conf, bg, text int) string

func SetPassword

func SetPassword(password string, salt string) (verify string, err error)

SetPassword 根据明文密码和加盐值生成密码

func StringToInt

func StringToInt(e string) (int, error)

func StructToJsonStr

func StructToJsonStr(e interface{}) (string, error)

func UIntToString

func UIntToString(e uint) string

func White

func White(msg string) string

func Yellow

func Yellow(msg string) string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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