Documentation ¶
Index ¶
- func BuildRequestHeaderDic(req *http.Request) map[string]string
- func CharacterStringLength(str string) int
- func CharacterSubString(str string, begin int, end int) string
- func Commit(tx *gorm.DB)
- func Crc16Check(data []byte) []byte
- func FuncProxy(rawFunction interface{}, args ...interface{}) (interface{}, error)
- func FuncProxyWithoutReturn(rawFunction interface{}, args ...interface{})
- func GetBusinessNumber(bType int) string
- func GetByUrlWithoutParams(url string) ([]byte, error)
- func GetCacheKey(function interface{}, args ...interface{}) string
- func GetDayStrFromTime(timeTime time.Time) string
- func GetFmtStr(data interface{}) string
- func GetFunctionName(i interface{}, seps ...rune) string
- func GetMd5(b []byte) string
- func GetNoSplitFromTime(timeTime time.Time) string
- func GetRandNo(length int) string
- func GetSplitStrFromTime(timeTime time.Time) string
- func GetStrFromTime(timeTime time.Time) string
- func GetTimeFromDayStr(timeStr string) (time.Time, error)
- func GetTimeFromNoSprit(timeStr string) (time.Time, error)
- func GetTimeFromSpritStr(timeStr string) (time.Time, error)
- func GetTimeFromStr(timeStr string) (time.Time, error)
- func GoRoutine(function interface{}, args ...interface{})
- func HashStrAndConvertToInt(str string, lenth int) int
- func IdCardMask(idCard string) string
- func IdCardWithoutMonthDay(idCard string) string
- func InList(str string, list []string) bool
- func IsDir(path string) (bool, error)
- func IsFile(path string) (bool, error)
- func MailMask(mailAddress string) string
- func Max(a, b int) int
- func Min(a, b int) int
- func ModStr(s string, len uint32) uint32
- func PersonalNameMask(name string) string
- func RollbackUnlessCommitted(tx *gorm.DB)
- func SendRequest(client *http.Client, queryStrDic, headerDic map[string]string, ...) ([]byte, error)
- func SimpleCopyProperties(dst, src interface{}) (err error)
- func TypeIsError(inType reflect.Type) bool
- type CacheWrapper
- type HttpOption
- type HttpTrigger
- func (p *HttpTrigger) Execute(body interface{}) (*response.RetData, error)
- func (p *HttpTrigger) HttpGet(url string, retData interface{}) error
- func (p *HttpTrigger) HttpPost(url string, body interface{}, retData interface{}) error
- func (p *HttpTrigger) SendJsonRequest(client *http.Client, queryStrDic, headerDic map[string]string, ...) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRequestHeaderDic ¶
BuildRequestHeaderDic Description 把http请求头的数据,构造成HttpTrigger的HeaderDic。http请求头key对应的value列表中,只会取出第一个string
func CharacterStringLength ¶
CharacterStringLength 字符串字符长度,即支持中英文混用 i"原字符串"
func CharacterSubString ¶
CharacterSubString 截取字符串,下标为字符计数,即支持中英文混用 str:"原字符串" begin:"起始位置" end:"终止位置+1"
func FuncProxy ¶
func FuncProxy(rawFunction interface{}, args ...interface{}) (interface{}, error)
FuncProxy case: 一个返回值; 一个返回值+error; error
func FuncProxyWithoutReturn ¶
func FuncProxyWithoutReturn(rawFunction interface{}, args ...interface{})
FuncProxyWithoutReturn case:无返回值
func GetBusinessNumber ¶
GetBusinessNumber func getBusinessNumber
func GetByUrlWithoutParams ¶
GetByUrlWithoutParams 从url直接获取返回 @Description: 从url直接获取返回 @param url @return []byte @return error
func GetCacheKey ¶
func GetCacheKey(function interface{}, args ...interface{}) string
GetCacheKey 获取缓存key
func GetDayStrFromTime ¶
GetDayStrFromTime with format "2006-01-02 15:04:05"
func GetFunctionName ¶
GetFunctionName 例如对于方法"runtime/debug.FreeOSMemory",sep不填,则输出该字符串;sep为'.',则输出"FreeOSMemory"
func GetNoSplitFromTime ¶
GetNoSplitFromTime with format "20060102 15:04:05"
func GetSplitStrFromTime ¶
GetSplitStrFromTime with format "2006-01-02 15:04:05"
func GetStrFromTime ¶
GetStrFromTime with format "2006-01-02 15:04:05"
func GetTimeFromDayStr ¶
GetTimeFromDayStr with format "2006-01-02 15:04:05"
func GetTimeFromNoSprit ¶
GetTimeFromNoSprit with format "20060102 15:04:05"
func GetTimeFromSpritStr ¶
GetTimeFromSpritStr with format "2006-01-02 15:04:05"
func GetTimeFromStr ¶
GetTimeFromStr with format "2006-01-02 15:04:05"
func GoRoutine ¶
func GoRoutine(function interface{}, args ...interface{})
GoRoutine 开启协程,已处理好panic。 @function 无返回值 @args function的参数
func HashStrAndConvertToInt ¶
HashStrAndConvertToInt func HashStrAndConvertToInt
func IdCardMask ¶
IdCardMask Description: 只留前3后2,隐藏13位 idCard 身份证号 return: string 隐藏后的身份证号
func IdCardWithoutMonthDay ¶
IdCardWithoutMonthDay id card cut month and day
func PersonalNameMask ¶
PersonalNameMask @Description: 只保留姓氏,复姓两字,name 姓名 return: string 隐藏后的姓名
func RollbackUnlessCommitted ¶
RollbackUnlessCommitted func
func SendRequest ¶
func SendRequest(client *http.Client, queryStrDic, headerDic map[string]string, method, reqUrl string, body interface{}, from, to string, disableReqBodyPrint, disableRespPrint bool, queryStr string) ([]byte, error)
SendRequest common func, send request
func SimpleCopyProperties ¶
func SimpleCopyProperties(dst, src interface{}) (err error)
SimpleCopyProperties 浅拷贝src的同名字段到dst dst必须是指针,涉及的字段必须是大写开头,src最好也是指针 如果字段内有引用类型如Slice,Map等,用此方法完成拷贝后,src的引用类型属性内容发生了改变,dst对应的属性中内容也会改变
Types ¶
type CacheWrapper ¶
CacheWrapper cache wrapper
func (*CacheWrapper) Do ¶
func (p *CacheWrapper) Do(result interface{}, function interface{}, args ...interface{}) error
Do 缓存函数执行的结果,主要用于db相关的单个返回值的查询方法的结果缓存。 @result 缓存的function返回值,必须为指针 @function 返回类型必须为:单个返回值或者单个返回值+error。如果有error且不为nil,则在Do的error里返回 @args function的参数
type HttpTrigger ¶
type HttpTrigger struct { Method string Url string From string To string DisableReqBodyPrint bool DisableRespBodyPrint bool HeaderDic map[string]string QueryDic map[string]string Client *http.Client QueryStr string //如果不为空,则忽略QueryDic }
HttpTrigger struct http trigger
func (*HttpTrigger) Execute ¶
func (p *HttpTrigger) Execute(body interface{}) (*response.RetData, error)
Execute send and get response
func (*HttpTrigger) HttpGet ¶
func (p *HttpTrigger) HttpGet(url string, retData interface{}) error
HttpGet JSON Get请求,需要服务端的响应体格式符合RetData resp必须是结构体的指针,字段是响应Data的内容 响应报文JSON的key,需要和respData中的字段名相同(忽略大小写),所以key最好是驼峰命名。否则需要在respData的字段标签中用指定名称,例如`mapstructure:"user_name"`
func (*HttpTrigger) HttpPost ¶
func (p *HttpTrigger) HttpPost(url string, body interface{}, retData interface{}) error
HttpPost JSON Post请求,需要服务端的响应体格式符合RetData body和resp必须是结构体的指针,resp字段是响应Data的内容 响应报文JSON的key,需要和respData中的字段名相同(忽略大小写), 所以key最好是驼峰命名。否则需要在respData的字段标签中用指定名称,例如`mapstructure:"user_name"`
func (*HttpTrigger) SendJsonRequest ¶
func (p *HttpTrigger) SendJsonRequest(client *http.Client, queryStrDic, headerDic map[string]string, body interface{}) ([]byte, error)
SendJsonRequest func sendJsonRequest