Skip to content

Go开源库大全

收集一些开源的go第三方库和框架做一个整理分类,方便后续浏览,也欢迎提交 pr 添加新的项目。

TIP

先后顺序不代表排名,好不好用要根据实际体验来看。

Web 框架

名称描述仓库
gin最经典的 web 框架https://github.com/gin-gonic/gin
beego国人开发的 web 框架https://github.com/beego/beego
iris号称最快的 web 框架https://github.com/kataras/iris
echo极简高性能的 web 框架https://github.com/labstack/echo
goji简洁的 web 框架https://github.com/zenazn/goji
revel高可用的全栈 web 框架https://github.com/revel/revel
buffalo可以简单的构建全栈项目 web 框架https://github.com/gobuffalo/buffalo
hertz具有高性能和强扩展性的微服务 HTTP 框架(字节开源)https://github.com/cloudwego/hertz
dotweb一个简单的微型 web 框架https://github.com/devfeel/dotweb
fiberNode.js Express 风格的 Web 框架https://github.com/gofiber/fiber

ORM

名称描述仓库
gorm开发者友好的 ORM 库https://github.com/go-gorm/gorm
xorm简单强大的 ORMhttps://gitea.com/xorm/xorm
entFaceBook 开源的 ORMhttps://github.com/ent/ent
sqlx对 sql 库的强大拓展https://github.com/jmoiron/sqlx
beego/ormbeego 自带的 ormhttps://github.com/astaxie/beego/tree/master/orm
rel可拓展的现代 ORMhttps://github.com/go-rel/rel
bunSQL 优先的 ORMhttps://github.com/uptrace/bun

微服务框架

名称描述仓库
kratos云原生微服务框架(B 站开源)https://github.com/go-kratos/kratos
go-kit一个微服务开发的工具库https://github.com/go-kit/kit
kitex高性能和高拓展的微服务框架(字节开源)https://github.com/cloudwego/kitex
go-zero云原生微服务框架(七牛云开源)https://github.com/zeromicro/go-zero
go-micro一个国外的微服务框架https://github.com/go-micro/go-micro
kite微服务框架(很久没更新)https://github.com/koding/kite
dubbo-gojava dubbo 在 go 实现(阿里开源)https://github.com/apache/dubbo-go
tarsgotars 在 go 中的实现(腾讯开源)https://github.com/TarsCloud/TarsGo
juptiers面向治理的微服务框架(斗鱼开源)https://github.com/douyu/jupiter
redsyncredis 分布式锁https://github.com/go-redsync/redsync

彩蛋

斗鱼的 jupiter 是宙斯的名字,是众神之神,而 B 站的 kratos 是战神奎托斯的名字,奎托斯后来杀掉了众神之神宙斯。

日志组件

名称描述仓库
logrus结构化日志库https://github.com/sirupsen/logrus
zapuber 开源的高性能日志库https://github.com/uber-go/zap
glog分级执行日志https://github.com/golang/glog
zerolog零内存分配的 json 日志https://github.com/rs/zerolog
apex/log结构化日志库https://github.com/apex/log
lumberjack日志分割库,支持大小分割,日期分割,文件压缩https://github.com/natefinch/lumberjack

测试组件

名称描述仓库
testify最流行的测试工具包https://github.com/stretchr/testify
ginkgo现代化的测试框架https://github.com/onsi/ginkgo
ramsql基于内存的 SQL 引擎,主要用于 SQL 的单元测试https://github.com/proullon/ramsql
go-sqlmock用于测试的 SQL Mockhttps://github.com/DATA-DOG/go-sqlmock
goconvey在浏览器可视化中测试https://github.com/smartystreets/goconvey
go-stress-testing压测工具https://github.com/link1st/go-stress-testing
xgogo 打桩测试框架,通过编译期重写代码来实现https://github.com/xhd2015/xgo
gomonkeygo 打桩测试框架,通过修改修改函数地址实现https://github.com/agiledragon/gomonkey

数据处理

名称描述仓库
mapstructuremap 与结构体互转https://github.com/mitchellh/mapstructure
cast可以很方便的数据类型转换https://github.com/spf13/cast
deepcopy深度复制https://github.com/mohae/deepcopy
copier可以在结构体之间同名字段复制值https://github.com/jinzhu/copier
go-pinyin汉字转拼音https://github.com/mozillazg/go-pinyin
go-streams流式数据处理https://github.com/reugn/go-streams
stream流式处理https://github.com/xyctruth/stream
go-humanize将数据转换成人类可以阅读的格式https://github.com/dustin/go-humanize
uniseg在 Go 中进行 Unicode 文本分段、字包装和字符串宽度计算https://github.com/rivo/uniseg

数据验证

名称描述仓库
go-playground/validator/v10数据验证器https://github.com/go-playground/validator
go-cmp谷歌开源的用于比较值的库https://github.com/google/go-cmp
ozzo-validation基于规则的数据校验库https://github.com/go-ozzo/ozzo-validation
go-tagexpr结构体 tag 验证库https://github.com/bytedance/go-tagexpr

数据结构

名称描述仓库
gods常见数据结构的实现https://github.com/emirpasic/gods
go-datastructures常见数据结构的实现https://github.com/Workiva/go-datastructures
bisetgo 中 bitsets 的实现https://github.com/bits-and-blooms/bitset
bloomgo 中 bloom filters 的实现https://github.com/bits-and-blooms/bloom
deque高性能双端队列的实现https://github.com/edwingeng/deque
concurrent-map并发安全的分片 map 实现https://github.com/orcaman/concurrent-map
samber/loLodash 风格的数据处理库,支持泛型https://github.com/samber/lo
google/btree谷歌实现的 BTree 库,支持泛型https://github.com/google/btree
gostl像 C++STL 一样的数据结构库https://github.com/liyue201/gostl

数学计算

名称描述仓库
gonum类比 numpyhttps://github.com/gonum/gonum
decimal高精度浮点数操作库https://github.com/shopspring/decimal
crunch一个简化字节和位操作的库https://github.com/superwhiskers/crunch
math-engine数学表达式解析计算引擎库https://github.com/dengsgo/math-engine

模板引擎

名称描述仓库
pongo2Django 风格的模板引擎https://github.com/flosch/pongo2
acehtml 模板引擎https://github.com/yosssi/ace
mustachemustache 在 go 中的实现https://github.com/hoisie/mustache
hero功能强大,快速的模板引擎https://github.com/shiyanhui/hero
quictemplate顾名思义,高性能的模板引擎https://github.com/valyala/quicktemplate
amber源于 HAML 和 Jade 的模板引擎https://github.com/eknkc/amber

缓存组件

名称描述仓库
golang-lru线程安全的 LRU,以及 LRU 2Q 缓存https://github.com/hashicorp/golang-lru
ttlcache基于内存的缓存,支持 TTL,泛型https://github.com/jellydator/ttlcache
gocache缓存中间件管理器https://github.com/eko/gocache
go-cache基于内存的缓存,适用于单机应用,支持 TTLhttps://github.com/patrickmn/go-cache
ristretto高性能的内存缓存https://github.com/dgraph-io/ristretto
bigcache基于内存的高效率的大 key 缓存https://github.com/allegro/bigcache

数据库&驱动

名称描述仓库
modernc.org/sqlitesqlite 驱动,纯 go 编写,不需要 cgohttps://gitlab.com/cznic/sqlite
mattn/go-sqlite3sqlite 驱动,需要 cgohttps://github.com/mattn/go-sqlite3
denisenkom/go-mssqldbsqlserver 驱动,不怎么更新了,建议使用微软的版本https://github.com/denisenkom/go-mssqldb
microsoft/go-mssqldbsqlserver 驱动,微软 fork 的新分支并维护https://github.com/microsoft/go-mssqldb
pgxpostgreSQL 驱动https://github.com/jackc/pgx/
mysqlmysql 驱动https://github.com/go-sql-driver/mysql
oci-go-sdkoracle 官方驱动https://github.com/oracle/oci-go-sdk
go-oraoracle 驱动,纯 go 编写https://github.com/sijms/go-ora
badger嵌入式的 kv 数据库,基于 LSMhttps://github.com/dgraph-io/badger
boltdb嵌入式的 kv 数据库,基于 B+Treehttps://github.com/boltdb/bolt
goleveldbgo 语言实现的 leveldbhttps://github.com/syndtr/goleveldb
qmgo七牛云开源的 mongodb 操作库https://github.com/qiniu/qmgo
mongo-go-drivermongodb 官方的 go 驱动https://github.com/mongodb/mongo-go-driver
rqlite基于 sqlite 的轻量级分布式关系数据库https://github.com/rqlite/rqlite/
go-mysql一个强大的 MySQL 工具集合https://github.com/go-mysql-org/go-mysql
go-mysql-elasticsearchMySQL 数据同步到 Elasticsearch 的工具https://github.com/go-mysql-org/go-mysql-elasticsearch
gofound单机亿级全文检索引擎,https://github.com/sea-team/gofound
bleve全文检索库https://github.com/blevesearch/bleve

序列化

名称描述仓库
go-iniini 文件序列化库https://github.com/go-ini/ini
sonic字节开源的高性能 json 序列化库https://github.com/bytedance/sonic
easyjsonjson 快速序列化库https://github.com/mailru/easyjson
gjson快速获取 json 键值,非传统的序列化库https://github.com/tidwall/gjson
go-yamlyaml 序列化库https://github.com/go-yaml/yaml
go-tomltoml 序列化库https://github.com/pelletier/go-toml
propertiesproperties 序列化库https://github.com/magiconair/properties
viper支持多种数据格式序列化,同时也是配置管理器https://github.com/spf13/viper
configorgorm 作者写的多种数据格式序列化器,配置管理器https://github.com/jinzhu/configor

命令行

名称描述仓库
pflagPOSIX/GUN 的风格的 flag 包https://github.com/spf13/pflag
go-flags命令参数解析器https://github.com/jessevdk/go-flags
cobra现代命令行程序构建脚手架https://github.com/spf13/cobra
dimiro1/banner美观的 banner 构建库https://github.com/dimiro1/banner
go-pretty输出美观的命令行表格,文字,进度条https://github.com/jedib0t/go-pretty
progressbar线程安全的命令行进度条https://github.com/schollz/progressbar
go-ansi用于 Go 语言的 Windows 便携式 ANSI 转义序列实用程序https://github.com/k0kubun/go-ansi
go-isatty用于判断 tty 的库https://github.com/mattn/go-isatty

压缩解压

名称描述仓库
klauspost/compress对 compress 标准库的优化改造https://github.com/klauspost/compress
alexmullins/ziparchive/zip 标准库的 fork 分支,支持密码https://github.com/alexmullins/zip
mholt/archiver支持很多格式的压缩解压缩工具库(个人非常推荐)https://github.com/mholt/archiver
go-carCAR 归档文件在 go 中的实现https://github.com/ipld/go-car
go-unarr一个压缩解压缩库https://github.com/gen2brain/go-unarr
xz用于读写 xz 压缩文件的纯 Golang 库https://github.com/ulikunitz/xz

时期时间

名称描述仓库
carbon时间日期处理库https://github.com/golang-module/carbon
robfig/cron定时任务库https://pkg.go.dev/github.com/robfig/cron/v3
gron定时任务库https://github.com/roylee0704/gron
jobrunner异步定时任务框架https://github.com/bamzi/jobrunner
dataparse可以在不知道格式的情况下解析时间字符串https://github.com/araddon/dateparse
jinzhu/now日期工具库https://github.com/jinzhu/now

依赖注入

名称描述仓库
diguber 开源的依赖注入库,基于反射https://darjun.github.io/2020/02/22/godailylib/dig/
wire谷歌开源的依赖注入库,基于代码生成https://github.com/google/wire
inject依赖注入工具https://github.com/codegangsta/inject
di依赖注入容器https://github.com/sarulabs/di

地理位置

名称描述仓库
geoip2-golangIP 转地理信息https://github.com/oschwald/geoip2-golang
ip2location-goIP 转地理信息https://github.com/ip2location/ip2location-go

爬虫框架

名称描述仓库
colly简单强大的爬虫框架https://github.com/gocolly/colly
goquery类似 j-thinghttps://github.com/PuerkitoBio/goquery

网络工具

名称描述仓库
gentleman插件驱动,可拓展的 http 客户端https://github.com/h2non/gentleman
restyrestful http 客户端https://pkg.go.dev/github.com/go-resty/resty/v2
gopeed支持所有平台的现代下载管理器,基于 go 和 flutterhttps://github.com/GopeedLab/gopeed

电子邮件

名称描述仓库
jordan-wright/email健壮灵活的邮件发送库https://github.com/jordan-wright/email
gomail邮件发送库https://github.com/go-gomail/gomail
go-simple-mail简单的邮件发送库https://github.com/xhit/go-simple-mail
go-mail易于使用,全面的邮件发送库https://github.com/wneessen/go-mail
email-verifier验证邮箱是否有效,且不需要发送邮件https://github.com/AfterShip/email-verifier
maddy组合式的邮件服务器https://github.com/foxcpp/maddy
mox全面开源,高维护性,自托管的邮件服务端https://github.com/mjl-/mox
hermes邮件模板生成库https://github.com/matcornic/hermes
listmonk高性能,子托管,可视化的邮件列表管理https://github.com/knadh/listmonk
go-smtpgo 编写的 SMTP 客户端与服务端https://github.com/emersion/go-smtp
go-imapgo 编写的 IMAP 客户端与服务端https://github.com/emersion/go-imap

游戏开发

名称描述仓库
ebitengine一个超级简单的 2d 游戏引擎https://github.com/hajimehoshi/ebiten
Azul3D一个由 go 编写的 3d 游戏引擎https://github.com/azul3d/engine
engo由 go 编写的开源 2d 游戏引擎https://github.com/EngoEngine/engo
g3n/enginego3d 游戏引擎https://github.com/g3n/engine
gonet一个游戏服务端框架https://github.com/xtaci/gonet
leaf游戏服务端框架https://github.com/name5566/leaf
cloud-game基于 web 的云游戏服务https://github.com/giongto35/cloud-game

GUI

名称描述仓库
fyne跨平台的 GUI 开发工具箱(真有点东西)https://github.com/fyne-io/fyne
go-flutter用 go 写 flutterhttps://github.com/go-flutter-desktop/go-flutter
Wails可以将它看作为 Go 的快并且轻量的 Electron 替代品https://github.com/wailsapp/wails

系统交互

名称描述仓库
gopsutil获取操作系统信息,兼容主流系统https://github.com/shirou/gopsutil
flock基于操作系统调用的文件锁https://github.com/gofrs/flock
sys官方的操作系统交互库https://cs.opensource.google/go/x/sys

跨语言交互

名称描述仓库
gopher-luago 编写的 lua 虚拟机https://github.com/yuin/gopher-lua
go-luago 编写的 lua 虚拟机https://github.com/Shopify/go-lua
goja支持 es5.1+https://github.com/dop251/goja
tengoTengo 是一种小型、动态、快速、安全的 Go 脚本语言https://github.com/d5/tengo
goby受 ruby 启发,由 go 实现的一种解释型脚本语言https://github.com/goby-lang/goby
go+七牛云开源的脚本语言,可以与 go 无缝交互,又称 Q 语言https://github.com/goplus/gop
go-pythongo 调用 cpython2https://github.com/sbinet/go-python
go-pytyon3go 调用 cpython3https://github.com/DataDog/go-python3

图像处理

名称描述仓库
plot一个绘图库,多用于数据可视化https://github.com/gonum/plot
gg2d 绘图库https://github.com/fogleman/gg
gocv支持 opencv4+https://github.com/hybridgroup/gocv
imaging一个简单的图像处理库https://github.com/disintegration/imaging

文字处理

名称描述仓库
vale语法感知的文本校对工具https://github.com/errata-ai/vale

认证授权

名称描述仓库
casbin灵活强大的权限管理库https://github.com/casbin/casbin
openfga高性能权限/授权库,源于 oogle Zanzibarhttps://github.com/openfga/openfga

代码生成

名称描述仓库
jennifer代码生成库https://github.com/dave/jennifer

正则处理

名称描述仓库
commonregx一个收集了常用的正则表达式的库https://github.com/mingrammer/commonregex

文件处理

名称描述仓库
filebox文件操作工具库https://github.com/dstgo/filebox
size快速完成文件大小与字符串之间的转换https://github.com/dstgo/size
checksum一个计算文件哈希签名的库https://github.com/codingsince1985/checksum
pdfcpupdf 处理器https://github.com/pdfcpu/pdfcpu
uniofficeoffice 处理库https://github.com/unidoc/unioffice
gooxmloffice 处理库https://github.com/carmel/gooxml
pdfcpuPDF 处理库https://github.com/pdfcpu/pdfcpu
excelizeExcel 处理库https://github.com/360EntSecGroup-Skylar/excelize

通用工具

名称描述仓库
lancet多功能工具库,类比 java 中的 common 包https://github.com/duke-git/lancet
bytebufferpool字节缓存池https://github.com/valyala/bytebufferpool

开发框架

名称描述仓库
goframe现代企业级 go 开发框架https://github.com/gogf/gf

共识协议

名称描述仓库
hashicorp/raftconsul 开源的 raft 库https://github.com/hashicorp/raft
hashicorp/memberlistconsul 开源的 gossip 库https://github.com/hashicorp/memberlist
etcd-io/raftetcd 开源的 raft 库https://github.com/etcd-io/raft

OCR

名称描述仓库
gosseract使用 Tesseract C + + 库的 OCR 库https://github.com/otiai10/gosseract

Golang学习网由www.golangdev.cn整理维护