tools

package
v0.0.0-...-594642b Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeDev  Mode = "dev"
	ModeTest Mode = "test"
	ModeProd      = "prod"
	Mysql         = "mysql"
	Sqlite        = "sqllite3"
)
View Source
const (
	TextBlack = iota + 30
	TextRed
	TextGreen
	TextYellow
	TextBlue
	TextMagenta
	TextCyan
	TextWhite
)

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 FormatTimeStr

func FormatTimeStr(timeStr string) (string, error)

func GenerateFromPassword

func GenerateFromPassword(p string, cost int) (string, error)

func GetBodyString

func GetBodyString(c *gin.Context) (string, error)

func GetCurrentTime

func GetCurrentTime() time.Time

func GetCurrentTimeStr

func GetCurrentTimeStr() string

func GetLocaHonst

func GetLocaHonst() string

获取局域网ip地址

func GetLocation

func GetLocation(ip string) string

获取外网ip地址

func GetUserIdStr

func GetUserIdStr(c *gin.Context) string

func GetUserIdUint64

func GetUserIdUint64(c *gin.Context) uint64

func Green

func Green(msg string) string

func HasError

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

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

func IdsStrToIdsIntGroup

func IdsStrToIdsIntGroup(key string, c *gin.Context) []int

获取URL中批量id并解析

func IdsStrToIdsIntGroupStr

func IdsStrToIdsIntGroupStr(keys string) []int

func Int64ToString

func Int64ToString(e int64) string

func IntToString

func IntToString(e int) string

func JsonStrToMap

func JsonStrToMap(e string) (map[string]interface{}, error)

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 StringToBool

func StringToBool(e string) (bool, error)

func StringToInt

func StringToInt(e string) (int, error)

func StringToInt64

func StringToInt64(e string) (int64, error)

func StringToUInt64

func StringToUInt64(e string) (uint64, error)

func StringToUint8

func StringToUint8(e string) (uint8, error)

func StructToJsonStr

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

func StructToMap

func StructToMap(data interface{}) (map[string]interface{}, error)

func White

func White(msg string) string

func Yellow

func Yellow(msg string) string

Types

type Ids

type Ids struct {
	Ids []int
}

type Mode

type Mode string

Directories

Path Synopsis
app
msg

Jump to

Keyboard shortcuts

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