Documentation ¶
Index ¶
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Delete(urlStr string, values url.Values, obj interface{}, opions ...NetOptionFunc) error
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func FormDataPost(url string, data map[string]string, obj interface{}, options ...NetOptionFunc) error
- func Get(urlStr string, values url.Values, obj interface{}, opions ...NetOptionFunc) error
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func InternetCheck(netLogLevel NetLogLevel, switchAction ...func(isOnline bool)) bool
- func LoadFile(path string) []byte
- func Log(args ...interface{})
- func Logf(format string, args ...interface{})
- func Logln(args ...interface{})
- func MD5(v string) string
- func Patch(url string, data interface{}, obj interface{}, options ...NetOptionFunc) error
- func Post(url string, data interface{}, obj interface{}, config ...NetOptionFunc) error
- func Put(url string, data interface{}, obj interface{}, options ...NetOptionFunc) error
- func RemoveDuplicateElementArray(sourceArray []string) []string
- func SaveFile(path string, data []byte)
- func SetBaseFormat(...)
- func SetLogger(yourLogger Logger)
- func TimeCost(signs ...string) func()
- func WaitHandle(channel chan interface{}, goCount int, waitingFor func(), ...)
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- type LogOptionFunc
- type Logger
- type NetLogLevel
- type NetOptionFunc
- func LogCallerSkipOption(logCallerSkip int) NetOptionFunc
- func LogLineSkipOption(logLineSkip int) NetOptionFunc
- func NetHeader(header http.Header) NetOptionFunc
- func NetLogLevelOption(netLogLevel NetLogLevel) NetOptionFunc
- func Timeout(timeout time.Duration) NetOptionFunc
- func UnmarshalPath(unmarshalPath []interface{}) NetOptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(urlStr string, values url.Values, obj interface{}, opions ...NetOptionFunc) error
Delete obj : body所序列化的对象, 指针类型, 如果为*http.Response类型, 则直接返回*http.Response
func FormDataPost ¶
func FormDataPost(url string, data map[string]string, obj interface{}, options ...NetOptionFunc) error
FormDataPost obj : body所序列化的对象, 指针类型, 如果为*http.Response类型, 则直接返回*http.Response
func Get ¶
func Get(urlStr string, values url.Values, obj interface{}, opions ...NetOptionFunc) error
Get obj : body所序列化的对象, 指针类型, 如果为*http.Response类型, 则直接返回*http.Response
func InternetCheck ¶
func InternetCheck(netLogLevel NetLogLevel, switchAction ...func(isOnline bool)) bool
InternetCheck 网络检测是否在线
func Patch ¶
func Patch(url string, data interface{}, obj interface{}, options ...NetOptionFunc) error
Patch obj : body所序列化的对象, 指针类型, 如果为*http.Response类型, 则直接返回*http.Response
func Post ¶
func Post(url string, data interface{}, obj interface{}, config ...NetOptionFunc) error
Post obj : body所序列化的对象, 指针类型, 如果为*http.Response类型, 则直接返回*http.Response
func Put ¶
func Put(url string, data interface{}, obj interface{}, options ...NetOptionFunc) error
Put obj : body所序列化的对象, 指针类型, 如果为*http.Response类型, 则直接返回*http.Response
func RemoveDuplicateElementArray ¶
RemoveDuplicateElementArray 去重
func SetBaseFormat ¶
func SetBaseFormat(block func(timeStr string, level string, funcName string, line int) (format string, args []interface{}))
SetBaseFormat 设置基本信息相关format格式, 默认为: "%s__%s__%s__第%d行__: " 和 []interface{}{timeStr, level, funName, codeLine}
func WaitHandle ¶
func WaitHandle(channel chan interface{}, goCount int, waitingFor func(), asyncHandle func(channelObj interface{}))
WaitHandle 阻塞型协程队列, 所有参数必传才执行
Types ¶
type LogOptionFunc ¶ added in v3.1.0
type LogOptionFunc func(o *logOptions)
LogOptionFunc for web
func LogCallerSkip ¶
func LogCallerSkip(callerSkip int) LogOptionFunc
LogCallerSkip 输出的方法名的层级, 默认为0, 代表输出当前方法名, 如果要输出上层方法名(比如闭包内打印), 则该参数设置为LogCallerSkip(1)即可, 以此类推.
func LogCondition ¶
func LogCondition(condition bool) LogOptionFunc
LogCondition 打印条件, 为true才打印, 默认true
func LogLineSkip ¶
func LogLineSkip(lineSkip int) LogOptionFunc
LogLineSkip 输出的行号的层级, 默认为0, 代表输出当前所在代码块的行号, 如果要输出上层代码块的行号(比如闭包内打印), 则该参数设置为LogLineSkip(1)即可, 以此类推.
type Logger ¶
type Logger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) }
Logger go-tools支持集成其他logger(调用SetLogger方法设置). 前提是要支持下方定义的Logger接口.
type NetLogLevel ¶
type NetLogLevel int
NetLogLevel 日志级别
const ( // 如果不需要打印, 请设置为NetLogNone, NetLogNil只是缺省值, 没有实际意义, 设置为NetLogNil相当于设置为NetLogAllWithoutObj NetLogNil NetLogLevel = NetLogLevel(0) NetLogNone NetLogLevel = 1 << iota NetLogURL NetLogParams NetLogResponse // LogObj 打印反序列化后的obj NetLogObj NetLogError NetLogAllWithoutObj = NetLogURL | NetLogParams | NetLogResponse | NetLogError NetLogAll = NetLogAllWithoutObj | NetLogObj )
日志配置, 默认LogAllWithoutObj
type NetOptionFunc ¶ added in v3.1.0
type NetOptionFunc func(o *netOptions)
NetOptionFunc for web
func LogCallerSkipOption ¶ added in v3.1.0
func LogCallerSkipOption(logCallerSkip int) NetOptionFunc
LogCallerSkipOption 默认为0, 代表请求位置的方法所跳过的层数,如果想看tools内部打印所在的方法, 可以传-2
func LogLineSkipOption ¶ added in v3.1.0
func LogLineSkipOption(logLineSkip int) NetOptionFunc
LogLineSkipOption 默认为0, 代表请求位置的行号所跳过的层数,如果想看tools内部的打印所在的行, 可以传-2
func NetLogLevelOption ¶ added in v3.1.0
func NetLogLevelOption(netLogLevel NetLogLevel) NetOptionFunc
NetLogLevelOption default: NetLogAll
func UnmarshalPath ¶ added in v3.1.0
func UnmarshalPath(unmarshalPath []interface{}) NetOptionFunc
UnmarshalPath 仅当obj参数不为nil时有效, eg:[]interface{}{"a",0,"b"}, 将会解析a下面的第1个元素的b节点
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
* @Author: shenguanjiejie 835166018@qq.com * @Date: 2022-10-17 11:51:51 * @LastEditors: shenguanjiejie 835166018@qq.com * @LastEditTime: 2022-10-20 12:09:53 * @FilePath: /go-tools/main/main.go * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
* @Author: shenguanjiejie 835166018@qq.com * @Date: 2022-10-17 11:51:51 * @LastEditors: shenguanjiejie 835166018@qq.com * @LastEditTime: 2022-10-20 12:09:53 * @FilePath: /go-tools/main/main.go * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE |