Golang常用到的包
16.Asynq支持优先级队列、延迟队列
juejin.cn/post/718440…
1.Gin validator库参数校验
Go 使用validator进行后端数据校验_Jambo_ma的博客-CSDN博客
【搞定Go语言】第3天20:validator库参数校验若干实用技巧_就叫一片白纸的博客-CSDN博客
2.zap+gin
3.go项目标准目录
golang 编程规范 - 项目目录结构 | MakeOptim
golang开发目录结构 - Go语言中文网 - Golang中文社区 (studygolang.com)
4.golang 的代码调用链图工具
ofabry/go-callvis: Visualize call graph of a Go program using Graphviz (github.com)
5.热编译
# 安装rizla包
$ go get -u github.com/kataras/rizla
# 热重启方式启动iris项目
$ rizla main.go
cloud.tencent.com/developer/a…
其他工具
gowatch: blog.csdn.net/longzhoufen…
文件变动通知 通过定期轮询文件系统状态的方式工作: github.com/radovskyb/watcher 它基于操作系统的原生事件通知机制: github.com/fsnotify/fsnotify"
Go语言经典库使用分析(八)| 变量数据结构调试利器 go-spew | 飞雪无情的总结 (flysnow.org)
6.协程池:
stefantalpalaru/pool: Go worker pool (github.com)
duzy/worker: Easier Go Concurrency Framework (github.com)
7. 命令行交互
github.com/AlecAivazis/survey/v2
github.com/urfave/cli/v2
8.调用浏览器打开地址
github.com/pkg/browser
9.协程和协程池:
github.com/panjf2000/ants/v2 golang.org/x/sync/errgroup
10.请求速率限制
golang.org/x/time/rate
限流算法: jingling.im/posts/desig…
pandaychen.github.io/2020/07/12/…
11.合并多个结构体
github.com/imdario/mergo github.com/mitchellh/mapstructure struct转map github.com/fatih/structs
12.错误包
github.com/pkg/errors
13. uber
github.com/uber-go/aut… github.com/uber-go/gol… NilAway
14. son高性能、或字节的json包
15.处理ini 配置文件
goconfig
1.2.用户kafka消费,中间件,api等
- github.com/throttled/throttled/v2
2.处理map、slice github.com/samber/lo.g…
3.http 请求包 github.com/go-resty/resty/v2
4.并发 4.1使用 singleflight 来确保对于相同的查询,fetchData 只被调用一次 非常适合于减少对下游服务的压力、避免不必要的重复计算,以及提高应用程序的响应速度和效率。 golang.org/x/sync/singleflight
func (c *cutRepo) CutTextWithCache(ctx context.Context, text string) (cutQuestion *biz.CutQuestion, err error) { var ( md5Val = utils.MD5(text) ok bool singleFightRes interface{} ) // check cache cutQuestion, ok = c.cache.Get(md5Val) if ok { return } // single flight singleFightRes, err, _ = c.singleFighter.Do(md5Val, func() (interface{}, error) { ret, err := c.CutText(ctx, text) if err != nil { return nil, err } c.cache.Add(md5Val, ret) return ret, nil }) if err != nil { return nil, err } cutQuestion = singleFightRes.(*biz.CutQuestion) return }