utils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const AuthError = 3
View Source
const CaptchaError = 5
View Source
const FailureContent = "操作失败"
View Source
const NotFound = 2
View Source
const ResponseFailure = 1
View Source
const ResponseSuccess = 0
View Source
const ServerError = 4
View Source
const SuccessContent = "操作成功"

Variables

This section is empty.

Functions

func EscapeJson

func EscapeJson(s string) string

转义json特殊字符

func ExecShell added in v1.2.1

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

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

func FileExist

func FileExist(file string) bool

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

func FormatUnixEnv

func FormatUnixEnv(key, value string) string

格式化环境变量

func GBK2UTF8

func GBK2UTF8(s string) (string, bool)

GBK编码转换为UTF8

func InStringSlice

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

func IsWindows

func IsWindows() bool

判断当前系统是否是windows

func JsonResponseByErr

func JsonResponseByErr(err error) string

func Md5

func Md5(str string) string

生成32位MD5摘要

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 added in v1.2.1

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