From 58281dbf9174a3a8c0e027768233a9a5d5b237ad Mon Sep 17 00:00:00 2001 From: q191201771 <191201771@qq.com> Date: Sat, 13 Nov 2021 20:37:49 +0800 Subject: [PATCH] patch --- .gitignore | 2 +- README.md | 6 ++---- pkg/assert/assert.go | 9 ++++++--- pkg/bininfo/bininfo.go | 2 ++ pkg/nazahttp/file.go | 6 +++++- pkg/ratelimit/ratelimit.go | 6 ++++++ 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 69b3171..8ea2fc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /pkg/websocket -/pkg/nazabytes/ /pkg/tag /pkg/nazatime @@ -11,6 +10,7 @@ /demo/temp /demo/analyse_git_log /demo/analyse_wireshark_plain_txt_dissection +/demo/disksweeper/ /.idea /.trash diff --git a/README.md b/README.md index 3e0ac3c..38dde46 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ pkg/ ...... 源码包 |-- bininfo/ ...... 将编译时源码的git版本信息(当前commit log的sha值和commit message),编译时间,Go版本,平台打入程序中 |-- circularqueue ...... 底层基于切片实现的固定容量大小的FIFO的环形队列 |-- connection/ ...... 对net.Conn接口的二次封装 + |-- dataops/ ...... 数据处理 |-- defertaskthread ...... 执行延时任务 |-- fake/ ...... 实现一些常用的接口,hook一些不方便测试的代码 |-- filebatch/ ...... 文件批处理操作 @@ -41,6 +42,7 @@ pkg/ ...... 源码包 |-- mock/ ...... 模拟一些标准库中的常用接口,方便测试 |-- nazaatomic/ ...... 原子操作 |-- nazabits/ ...... 位操作 + |-- nazabytes/ ...... 字节切片,内存块操作 |-- nazacolor/ ...... 控制台打印颜色相关 |-- nazaerrors/ ...... error相关 |-- nazahttp/ ...... http操作 @@ -71,10 +73,6 @@ bin/ ...... 可执行文件编译输出目录 无任何第三方依赖 -#### 相关文档 - -https://pengrl.com/categories/Go/ - #### 联系我 欢迎扫码加我微信,进行技术交流或扯淡。 diff --git a/pkg/assert/assert.go b/pkg/assert/assert.go index d8e961a..b054962 100644 --- a/pkg/assert/assert.go +++ b/pkg/assert/assert.go @@ -6,12 +6,14 @@ // // Author: Chef (191201771@qq.com) -// package assert 提供了单元测试时的断言功能,减少一些模板代码 +// Package assert 提供了单元测试时的断言功能,减少一些模板代码 +// package assert import "github.com/q191201771/naza/pkg/nazareflect" -// 单元测试中的 *testing.T 和 *testing.B 都满足该接口 +// TestingT 单元测试中的 *testing.T 和 *testing.B 都满足该接口 +// type TestingT interface { Errorf(format string, args ...interface{}) } @@ -30,7 +32,8 @@ func Equal(t TestingT, expected interface{}, actual interface{}, msg ...string) return } -// 比如有时我们需要对 error 类型不等于 nil 做断言,但是我们并不关心 error 的具体值是什么 +// IsNotNil 比如有时我们需要对 error 类型不等于 nil 做断言,但是我们并不关心 error 的具体值是什么 +// func IsNotNil(t TestingT, actual interface{}, msg ...string) { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/pkg/bininfo/bininfo.go b/pkg/bininfo/bininfo.go index d89f5bc..53e9c9f 100644 --- a/pkg/bininfo/bininfo.go +++ b/pkg/bininfo/bininfo.go @@ -7,8 +7,10 @@ // Author: Chef (191201771@qq.com) // Package bininfo +// // 将编译时源码的git版本信息(当前tag,commit log的sha值和commit message,是否有未提交的修改),编译时间,Go版本,编译、运行平台打入程序中 // 编译时传入这些信息的方式见 naza 的编译脚本: https://github.com/q191201771/naza/blob/master/build.sh +// package bininfo import ( diff --git a/pkg/nazahttp/file.go b/pkg/nazahttp/file.go index 23088ec..a533946 100644 --- a/pkg/nazahttp/file.go +++ b/pkg/nazahttp/file.go @@ -16,7 +16,11 @@ import ( "time" ) -// 获取http文件保存至字节切片 +// TODO(chef): 重命名为GetAll +// +// GetHttpFile 获取http文件保存至字节切片 +// +// func GetHttpFile(url string, timeoutMs int) ([]byte, error) { var c http.Client if timeoutMs > 0 { diff --git a/pkg/ratelimit/ratelimit.go b/pkg/ratelimit/ratelimit.go index 6a9b7e7..edb5242 100644 --- a/pkg/ratelimit/ratelimit.go +++ b/pkg/ratelimit/ratelimit.go @@ -8,6 +8,12 @@ package ratelimit +// LeakBucket和TokenBucket的区别 +// +// LeakBucket: 业务方从LeakBucket获取资源的时间间隔必须>=设置的时间间隔 +// TokenBucket: 内部会持续生成资源并进行缓存,外部可以一次性获取 +// + type RateLimiter interface { TryAquire() error WaitUntilAquire()