Documentation ¶
Index ¶
- Variables
- func CheckError(err error)
- func Debug(info ...interface{})
- func FriendlyLoggerCreator(param string) (log.Logger, error)
- func InterfaceToStruct(input interface{}, ouput interface{}) error
- func MapToStruct(m map[string]interface{}, result interface{}) error
- func PostMultipartForm(url string, value map[string]string, file map[string]io.Reader) (*http.Response, error)
- func RandStringBytesMaskImprSrc(n int) string
- func ResolveHTTPRespToInterface(input *http.Response, output interface{}) error
- func ResolveStructToValues(data interface{}) *url.Values
- func SetField(obj interface{}, name string, value interface{}) error
- func TrimPathName(s string) string
- func TrimSpace(s string) string
- type FailReturn
- type FriendlyLogger
- func (this *FriendlyLogger) Async() bool
- func (this *FriendlyLogger) Close()
- func (this *FriendlyLogger) Closed() bool
- func (this *FriendlyLogger) Debug(info ...interface{})
- func (this *FriendlyLogger) Error(info ...interface{})
- func (this *FriendlyLogger) Fatal(info ...interface{})
- func (this *FriendlyLogger) Info(info ...interface{})
- func (this *FriendlyLogger) LogLevelOutput(level log.LogLevel) bool
- func (this *FriendlyLogger) SetAsync(async bool)
- func (this *FriendlyLogger) SetLogLevelOutput(level log.LogLevel, output bool)
- func (this *FriendlyLogger) SetSkip(skip int)
- func (this *FriendlyLogger) Warn(info ...interface{})
- type SuccessReturn
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // FailReturnCode10000 参数错误 FailReturnCode10000 = &FailReturn{10000, "参数错误,参数不符合接口要求!"} // FailReturnCode20000 登陆失败,用户名或密码错误 FailReturnCode20000 = &FailReturn{20000, "用户名或密码错误"} // FailReturnCode20001 用户未登录 FailReturnCode20001 = &FailReturn{20001, "用户未登录,请先登录!"} // FailReturnCode20002 用户权限不足 FailReturnCode20002 = &FailReturn{20002, "操作失败,用户权限不足!"} // FailReturnCode20003 在学习中心中,用户只有在未设置区域的情况下(省市均为0)才能设置区域 FailReturnCode20003 = &FailReturn{20003, "用户设置区域失败(用户不能重复设置区域)"} // FailReturnCode50000 服务器错误 FailReturnCode50000 = &FailReturn{50000, "服务器内部错误!"} )
View Source
var Logger log.Logger
Logger 控制台日志器
Functions ¶
func InterfaceToStruct ¶
func InterfaceToStruct(input interface{}, ouput interface{}) error
InterfaceToStruct 将interface{}类型转换成具体的struct
func MapToStruct ¶
MapToStruct 将map值解析到struct中去
func PostMultipartForm ¶
func PostMultipartForm(url string, value map[string]string, file map[string]io.Reader) (*http.Response, error)
PostMultipartForm 使用http post方式提交文件请求
func RandStringBytesMaskImprSrc ¶
RandStringBytesMaskImprSrc 生成随机n位长度的token
func ResolveHTTPRespToInterface ¶
ResolveHTTPRespToInterface 解析http response到结构体 output必须是结构体指针或map指针
func ResolveStructToValues ¶
ResolveStructToValues 解析结构体数据到url.Values中 如果data不是结构体,则返回nil
Types ¶
type FailReturn ¶
FailReturn 请求失败返回值
type FriendlyLogger ¶
type FriendlyLogger struct {
// contains filtered or unexported fields
}
func NewFriendlyLogger ¶
func NewFriendlyLogger(logWriter log.LogWriter, skip int) *FriendlyLogger
NewFriendlyLogger 创建日志记录器
func (*FriendlyLogger) LogLevelOutput ¶
func (this *FriendlyLogger) LogLevelOutput(level log.LogLevel) bool
LogLevel 得到日志等级是否输出
func (*FriendlyLogger) SetAsync ¶
func (this *FriendlyLogger) SetAsync(async bool)
SetAsync 设置是否异步输出
func (*FriendlyLogger) SetLogLevelOutput ¶
func (this *FriendlyLogger) SetLogLevelOutput(level log.LogLevel, output bool)
SetLogLevel 设置某个日志等级是否输出
func (*FriendlyLogger) SetSkip ¶
func (this *FriendlyLogger) SetSkip(skip int)
SetSkip skip为跳过的Caller数量,skip小于2时关闭文件位置记录的功能
type SuccessReturn ¶
type SuccessReturn struct { Code int Data interface{} }
SuccessReturn 请求成功返回值
func NewSuccessReturn ¶
func NewSuccessReturn(data interface{}) *SuccessReturn
NewSuccessReturn 创建一个成功返回值
Click to show internal directories.
Click to hide internal directories.