gotools

package
v0.0.0-...-9172e6a Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 22 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 DownloadFile

func DownloadFile(filePath string, rw http.ResponseWriter) error

DownloadFile 文件下载

func EscapeJson

func EscapeJson(s string) string

EscapeJson 转义json特殊字符

func ExecShell

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

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

func FileExist

func FileExist(file string) bool

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

func FormatAppVersion

func FormatAppVersion(appVersion, GitCommit, BuildDate string) (string, error)

FormatAppVersion 格式化应用版本信息

func GBK2UTF8

func GBK2UTF8(s string) (string, bool)

GBK2UTF8 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

Md5 生成32位MD5摘要

func PanicToError

func PanicToError(f func()) (err error)

PanicToError Panic转换为error

func PanicTrace

func PanicTrace(err interface{}) string

PanicTrace panic调用链跟踪

func PrintAppVersion

func PrintAppVersion(appVersion, GitCommit, BuildDate string)

PrintAppVersion 打印应用版本

func RandAuthToken

func RandAuthToken() string

func RandNumber

func RandNumber(max int) int

RandNumber 生成0-max之间随机数

func RandString

func RandString(length int64) string

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

func ReplaceStrings

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

ReplaceStrings 批量替换字符串

func WorkDir

func WorkDir() (string, error)

WorkDir 获取程序运行时根目录

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
}

type WaitGroupWrapper

type WaitGroupWrapper struct {
	sync.WaitGroup
}

WaitGroupWrapper waitGroup包装

func (*WaitGroupWrapper) Wrap

func (w *WaitGroupWrapper) Wrap(f func())

Wrap 包装Add, Done方法

Jump to

Keyboard shortcuts

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