util

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

util

Index

Constants

This section is empty.

Variables

Json

View Source
var Response = ResponseStruct{}

Response gloabl response fmt

View Source
var RestyClient = NewRestyClient()

RestyClient

Functions

func Bool2Int

func Bool2Int(a bool) int64

Bool2Int

@param a
@return int64

func CreateTempFile

func CreateTempFile(data []byte) (*os.File, error)

CreateTempFile

@param data
@return *os.File
@return error

func Exists

func Exists(path string) bool

Exists

@param path
@return bool

func GetUnixString

func GetUnixString() string

GetUnixString

@return string

func GetYMDStylePath

func GetYMDStylePath() string

GetYMDStylePath

@return string

func Md5hex

func Md5hex(input string) string

func NewRestyClient

func NewRestyClient() *resty.Client

func PostJSON

func PostJSON(url string, data interface{}, header map[string]string) (res []byte, err error)

PostJSON

@param url
@param data
@param header
@return res
@return err

func Retry

func Retry(attempts int, fn func() error) error

Retry 重试指定次数的函数调用

func Tnt2Bool

func Tnt2Bool(a int64) bool

Tnt2Bool

@param a
@return bool

func WithTimeoutRoutine

func WithTimeoutRoutine(td time.Duration, args interface{}, fc func(interface{}) (interface{}, error)) (interface{}, error)

WithTimeoutRoutine

@param td
@param args
@param fc
@return interface{}
@return error

Types

type ResponseStruct

type ResponseStruct struct{}

ResponseStruct

func (ResponseStruct) Error

func (r ResponseStruct) Error(ctx *gin.Context, data gin.H, msg string)

Error

@receiver r
@param ctx
@param data
@param msg

func (ResponseStruct) ResponsFmt

func (ResponseStruct) ResponsFmt(ctx *gin.Context, httpStatus int, code int, data gin.H, msg string)

ResponsFmt

@receiver ResponseStruct
@param ctx
@param httpStatus
@param code
@param data
@param msg

func (ResponseStruct) Success

func (r ResponseStruct) Success(ctx *gin.Context, data gin.H, msg string)

Success

@receiver r
@param ctx
@param data
@param msg

Jump to

Keyboard shortcuts

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