pull/3/head
q191201771 3 years ago
parent 9a0fe4df6a
commit 58281dbf91

2
.gitignore vendored

@ -1,5 +1,4 @@
/pkg/websocket /pkg/websocket
/pkg/nazabytes/
/pkg/tag /pkg/tag
/pkg/nazatime /pkg/nazatime
@ -11,6 +10,7 @@
/demo/temp /demo/temp
/demo/analyse_git_log /demo/analyse_git_log
/demo/analyse_wireshark_plain_txt_dissection /demo/analyse_wireshark_plain_txt_dissection
/demo/disksweeper/
/.idea /.idea
/.trash /.trash

@ -34,6 +34,7 @@ pkg/ ...... 源码包
|-- bininfo/ ...... 将编译时源码的git版本信息当前commit log的sha值和commit message编译时间Go版本平台打入程序中 |-- bininfo/ ...... 将编译时源码的git版本信息当前commit log的sha值和commit message编译时间Go版本平台打入程序中
|-- circularqueue ...... 底层基于切片实现的固定容量大小的FIFO的环形队列 |-- circularqueue ...... 底层基于切片实现的固定容量大小的FIFO的环形队列
|-- connection/ ...... 对net.Conn接口的二次封装 |-- connection/ ...... 对net.Conn接口的二次封装
|-- dataops/ ...... 数据处理
|-- defertaskthread ...... 执行延时任务 |-- defertaskthread ...... 执行延时任务
|-- fake/ ...... 实现一些常用的接口hook一些不方便测试的代码 |-- fake/ ...... 实现一些常用的接口hook一些不方便测试的代码
|-- filebatch/ ...... 文件批处理操作 |-- filebatch/ ...... 文件批处理操作
@ -41,6 +42,7 @@ pkg/ ...... 源码包
|-- mock/ ...... 模拟一些标准库中的常用接口,方便测试 |-- mock/ ...... 模拟一些标准库中的常用接口,方便测试
|-- nazaatomic/ ...... 原子操作 |-- nazaatomic/ ...... 原子操作
|-- nazabits/ ...... 位操作 |-- nazabits/ ...... 位操作
|-- nazabytes/ ...... 字节切片,内存块操作
|-- nazacolor/ ...... 控制台打印颜色相关 |-- nazacolor/ ...... 控制台打印颜色相关
|-- nazaerrors/ ...... error相关 |-- nazaerrors/ ...... error相关
|-- nazahttp/ ...... http操作 |-- nazahttp/ ...... http操作
@ -71,10 +73,6 @@ bin/ ...... 可执行文件编译输出目录
无任何第三方依赖 无任何第三方依赖
#### 相关文档
https://pengrl.com/categories/Go/
#### 联系我 #### 联系我
欢迎扫码加我微信,进行技术交流或扯淡。 欢迎扫码加我微信,进行技术交流或扯淡。

@ -6,12 +6,14 @@
// //
// Author: Chef (191201771@qq.com) // Author: Chef (191201771@qq.com)
// package assert 提供了单元测试时的断言功能,减少一些模板代码 // Package assert 提供了单元测试时的断言功能,减少一些模板代码
//
package assert package assert
import "github.com/q191201771/naza/pkg/nazareflect" import "github.com/q191201771/naza/pkg/nazareflect"
// 单元测试中的 *testing.T 和 *testing.B 都满足该接口 // TestingT 单元测试中的 *testing.T 和 *testing.B 都满足该接口
//
type TestingT interface { type TestingT interface {
Errorf(format string, args ...interface{}) Errorf(format string, args ...interface{})
} }
@ -30,7 +32,8 @@ func Equal(t TestingT, expected interface{}, actual interface{}, msg ...string)
return return
} }
// 比如有时我们需要对 error 类型不等于 nil 做断言,但是我们并不关心 error 的具体值是什么 // IsNotNil 比如有时我们需要对 error 类型不等于 nil 做断言,但是我们并不关心 error 的具体值是什么
//
func IsNotNil(t TestingT, actual interface{}, msg ...string) { func IsNotNil(t TestingT, actual interface{}, msg ...string) {
if h, ok := t.(tHelper); ok { if h, ok := t.(tHelper); ok {
h.Helper() h.Helper()

@ -7,8 +7,10 @@
// Author: Chef (191201771@qq.com) // Author: Chef (191201771@qq.com)
// Package bininfo // Package bininfo
//
// 将编译时源码的git版本信息当前tagcommit log的sha值和commit message是否有未提交的修改编译时间Go版本编译、运行平台打入程序中 // 将编译时源码的git版本信息当前tagcommit log的sha值和commit message是否有未提交的修改编译时间Go版本编译、运行平台打入程序中
// 编译时传入这些信息的方式见 naza 的编译脚本: https://github.com/q191201771/naza/blob/master/build.sh // 编译时传入这些信息的方式见 naza 的编译脚本: https://github.com/q191201771/naza/blob/master/build.sh
//
package bininfo package bininfo
import ( import (

@ -16,7 +16,11 @@ import (
"time" "time"
) )
// 获取http文件保存至字节切片 // TODO(chef): 重命名为GetAll
//
// GetHttpFile 获取http文件保存至字节切片
//
//
func GetHttpFile(url string, timeoutMs int) ([]byte, error) { func GetHttpFile(url string, timeoutMs int) ([]byte, error) {
var c http.Client var c http.Client
if timeoutMs > 0 { if timeoutMs > 0 {

@ -8,6 +8,12 @@
package ratelimit package ratelimit
// LeakBucket和TokenBucket的区别
//
// LeakBucket: 业务方从LeakBucket获取资源的时间间隔必须>=设置的时间间隔
// TokenBucket: 内部会持续生成资源并进行缓存,外部可以一次性获取
//
type RateLimiter interface { type RateLimiter interface {
TryAquire() error TryAquire() error
WaitUntilAquire() WaitUntilAquire()

Loading…
Cancel
Save