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整理維護