utils

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const AppNotInstall = 801
View Source
const AuthError = 401
View Source
const FailureContent = "操作失败"
View Source
const NotFound = 404
View Source
const ResponseFailure = 1
View Source
const ResponseSuccess = 0
View Source
const ServerError = 500
View Source
const SuccessContent = "操作成功"
View Source
const UnauthorizedError = 403

Variables

This section is empty.

Functions

func EscapeJson

func EscapeJson(s string) string

转义json特殊字符

func ExecShell

func ExecShell(ctx context.Context, command string) (string, error)

执行shell命令,可设置执行超时时间

func FileExist

func FileExist(file string) bool

判断文件是否存在及是否有权限访问

func GBK2UTF8

func GBK2UTF8(s string) (string, bool)

GBK编码转换为UTF8

func InStringSlice

func InStringSlice(slice []string, element string) bool

func JsonResponseByErr

func JsonResponseByErr(err error) string

func Md5

func Md5(str string) string

生成32位MD5摘要

func RandAuthToken

func RandAuthToken() string

func RandNumber

func RandNumber(max int) int

生成0-max之间随机数

func RandString

func RandString(length int64) string

生成长度为length的随机字符串

func ReplaceStrings

func ReplaceStrings(s string, old []string, replace []string) string

批量替换字符串

Types

type JsonResponse

type JsonResponse struct{}

func (*JsonResponse) CommonFailure

func (j *JsonResponse) CommonFailure(message string, err ...error) string

func (*JsonResponse) Failure

func (j *JsonResponse) Failure(code int, message string) string

func (*JsonResponse) Success

func (j *JsonResponse) Success(message string, data interface{}) string

type Result

type Result struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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