pkg

package
v1.3.24 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 26 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 FileCreate

func FileCreate(content bytes.Buffer, name string)

func FileMonitoringById

func FileMonitoringById(ctx context.Context, filePth string, id string, group string, hookfn func(context.Context, string, string, []byte))

func GenerateMsgIDFromContext

func GenerateMsgIDFromContext(c *gin.Context) string

GenerateMsgIDFromContext 生成msgID

func GenerateRandomKey16

func GenerateRandomKey16() string

GenerateRandomKey16 生成16为随机字符串

func GenerateRandomKey20

func GenerateRandomKey20() string

GenerateRandomKey20 生成20位随机字符串

func GenerateRandomKey6

func GenerateRandomKey6() string

GenerateRandomKey6 生成6为随机字符串

func Get

func Get(url string) (string, error)

发送GET请求 url: 请求地址 response: 请求返回的内容

func GetCurrentPath

func GetCurrentPath() string

获取当前路径,比如:E:/abc/data/test

func GetCurrentTime

func GetCurrentTime() time.Time

func GetCurrentTimeStr

func GetCurrentTimeStr() string

func GetFileSize

func GetFileSize(filename string) int64

获取文件大小

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 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 Magenta

func Magenta(msg string) string

func PathCreate

func PathCreate(dir string) error

func PathExist

func PathExist(addr string) bool

PathExist 判断目录是否存在

func Post

func Post(url string, data interface{}, contentType string) ([]byte, error)

发送POST请求 url: 请求地址 data: POST请求提交的数据 contentType: 请求体格式,如:application/json content: 请求放回的内容

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 Translate

func Translate(form, to interface{})

func UIntToString

func UIntToString(e uint) string

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
const (
	ModeDev  Mode = "dev"     //开发模式
	ModeTest Mode = "test"    //测试模式
	ModeProd Mode = "prod"    //生产模式
	Mysql         = "mysql"   //mysql数据库标识
	Sqlite        = "sqlite3" //sqlite
)

func (Mode) String

func (e Mode) String() string

type ReplaceHelper

type ReplaceHelper struct {
	Root    string //路径
	OldText string //需要替换的文本
	NewText string //新的文本
}

func (*ReplaceHelper) DoWrok

func (h *ReplaceHelper) DoWrok() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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