大家一起来参与讨论一下,那些 Go 的库让你相见恨晚,用了之后神清气爽?
goframe https://goframe.org/index
引用 nest.js 作者说的,大部分框架都没解决一个核心问题,架构。
https://github.com/golang/mock
以前写测试的时候 mock 数据太难了,特别是数据库的测试,有了这个库之后生活变得如此简单
mockgen database/sql/driver Conn,Driver
go-colly 高度可配置和可扩展,支持分布式抓取的 Web 爬虫框架,还支持多种存储后端(如内存、Redis、MongoDB 等)
@chenli @chenhui7373 给大家留个地址嘛,推荐理由
有没 soap 协议比较好的库,经常需要调用银行的 ESB 服务,基本都是 soap 协议,1.1,1.2 版本都有
https://pkg.go.dev/github.com/stretchr/testify
https://pkg.go.dev/github.com/golang/mock
https://pkg.go.dev/github.com/go-testfixtures/testfixtures/v3
https://pkg.go.dev/github.com/DATA-DOG/go-sqlmock
https://pkg.go.dev/github.com/onsi/ginkgo
https://pkg.go.dev/github.com/spf13/viper
https://pkg.go.dev/github.com/joho/godotenv
https://pkg.go.dev/go.uber.org/fx
https://pkg.go.dev/github.com/google/wire
https://pkg.go.dev/github.com/rs/zerolog
https://pkg.go.dev/github.com/pkg/errors
暂时想到这么多
都是比较偏的库,常用的不说了。
地址 | 类别 | 理由 |
---|---|---|
github.com/jmoiron/sqlx | 数据库 | 直接执行或绑定结构体 |
github.com/kr/pretty | 格式化 | 将对象全部信息格式化输出 |
github.com/creack/pty | 终端 | 可以启动一个 bash 终端 |
github.com/chromedp/chromedp | cdp | cdp 实现,前端分离后可以实现 ssr |
github.com/bradfitz/gomemcache | 驱动 | memcache 驱动实现,简单的 tcp 编程实现网络协议 |
Gin , 没有相见恨晚,只是一直在用
https://github.com/gingerhot/joker 开发环境检查工具
https://github.com/google/wire 在 golang 中使用依赖注入
一个非常好用的 HTTP 请求库:https://github.com/idoubi/goz
https://github.com/fatih/structs 可惜作者不再维护 了