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 |
| fiber | Node.js Express 風格的 Web 框架 | https://github.com/gofiber/fiber |
ORM
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| gorm | 開發者友好的 ORM 庫 | https://github.com/go-gorm/gorm |
| xorm | 簡單強大的 ORM | https://gitea.com/xorm/xorm |
| ent | FaceBook 開源的 ORM | https://github.com/ent/ent |
| sqlx | 對 sql 庫的強大拓展 | https://github.com/jmoiron/sqlx |
| beego/orm | beego 自帶的 orm | https://github.com/astaxie/beego/tree/master/orm |
| rel | 可拓展的現代 ORM | https://github.com/go-rel/rel |
| bun | SQL 優先的 ORM | https://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-go | java dubbo 在 go 實現(阿裡開源) | https://github.com/apache/dubbo-go |
| tarsgo | tars 在 go 中的實現(騰訊開源) | https://github.com/TarsCloud/TarsGo |
| juptiers | 面向治理的微服務框架(斗魚開源) | https://github.com/douyu/jupiter |
| redsync | redis 分布式鎖 | https://github.com/go-redsync/redsync |
彩蛋
斗魚的 jupiter 是宙斯的名字,是眾神之神,而 B 站的 kratos 是戰神奎托斯的名字,奎托斯後來殺掉了眾神之神宙斯。
日志組件
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| logrus | 結構化日志庫 | https://github.com/sirupsen/logrus |
| zap | uber 開源的高性能日志庫 | 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 Mock | https://github.com/DATA-DOG/go-sqlmock |
| goconvey | 在瀏覽器可視化中測試 | https://github.com/smartystreets/goconvey |
| go-stress-testing | 壓測工具 | https://github.com/link1st/go-stress-testing |
| xgo | go 打樁測試框架,通過編譯期重寫代碼來實現 | https://github.com/xhd2015/xgo |
| gomonkey | go 打樁測試框架,通過修改修改函數地址實現 | https://github.com/agiledragon/gomonkey |
數據處理
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| mapstructure | map 與結構體互轉 | 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 |
| biset | go 中 bitsets 的實現 | https://github.com/bits-and-blooms/bitset |
| bloom | go 中 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/lo | Lodash 風格的數據處理庫,支持泛型 | https://github.com/samber/lo |
| google/btree | 谷歌實現的 BTree 庫,支持泛型 | https://github.com/google/btree |
| gostl | 像 C++STL 一樣的數據結構庫 | https://github.com/liyue201/gostl |
數學計算
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| gonum | 類比 numpy | https://github.com/gonum/gonum |
| decimal | 高精度浮點數操作庫 | https://github.com/shopspring/decimal |
| crunch | 一個簡化字節和位操作的庫 | https://github.com/superwhiskers/crunch |
| math-engine | 數學表達式解析計算引擎庫 | https://github.com/dengsgo/math-engine |
模板引擎
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| pongo2 | Django 風格的模板引擎 | https://github.com/flosch/pongo2 |
| ace | html 模板引擎 | https://github.com/yosssi/ace |
| mustache | mustache 在 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 | 基於內存的緩存,適用於單機應用,支持 TTL | https://github.com/patrickmn/go-cache |
| ristretto | 高性能的內存緩存 | https://github.com/dgraph-io/ristretto |
| bigcache | 基於內存的高效率的大 key 緩存 | https://github.com/allegro/bigcache |
數據庫&驅動
序列化
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| go-ini | ini 文件序列化庫 | https://github.com/go-ini/ini |
| sonic | 字節開源的高性能 json 序列化庫 | https://github.com/bytedance/sonic |
| easyjson | json 快速序列化庫 | https://github.com/mailru/easyjson |
| gjson | 快速獲取 json 鍵值,非傳統的序列化庫 | https://github.com/tidwall/gjson |
| go-yaml | yaml 序列化庫 | https://github.com/go-yaml/yaml |
| go-toml | toml 序列化庫 | https://github.com/pelletier/go-toml |
| properties | properties 序列化庫 | https://github.com/magiconair/properties |
| viper | 支持多種數據格式序列化,同時也是配置管理器 | https://github.com/spf13/viper |
| configor | gorm 作者寫的多種數據格式序列化器,配置管理器 | https://github.com/jinzhu/configor |
命令行
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| pflag | POSIX/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/zip | archive/zip 標准庫的 fork 分支,支持密碼 | https://github.com/alexmullins/zip |
| mholt/archiver | 支持很多格式的壓縮解壓縮工具庫(個人非常推薦) | https://github.com/mholt/archiver |
| go-car | CAR 歸檔文件在 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 |
依賴注入
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| dig | uber 開源的依賴注入庫,基於反射 | 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-golang | IP 轉地理信息 | https://github.com/oschwald/geoip2-golang |
| ip2location-go | IP 轉地理信息 | https://github.com/ip2location/ip2location-go |
爬蟲框架
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| colly | 簡單強大的爬蟲框架 | https://github.com/gocolly/colly |
| goquery | 類似 j-thing | https://github.com/PuerkitoBio/goquery |
網絡工具
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| gentleman | 插件驅動,可拓展的 http 客戶端 | https://github.com/h2non/gentleman |
| resty | restful http 客戶端 | https://pkg.go.dev/github.com/go-resty/resty/v2 |
| gopeed | 支持所有平台的現代下載管理器,基於 go 和 flutter | https://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-smtp | go 編寫的 SMTP 客戶端與服務端 | https://github.com/emersion/go-smtp |
| go-imap | go 編寫的 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/engine | go3d 游戲引擎 | 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 寫 flutter | https://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-lua | go 編寫的 lua 虛擬機 | https://github.com/yuin/gopher-lua |
| go-lua | go 編寫的 lua 虛擬機 | https://github.com/Shopify/go-lua |
| goja | 支持 es5.1+ | https://github.com/dop251/goja |
| tengo | Tengo 是一種小型、動態、快速、安全的 Go 腳本語言 | https://github.com/d5/tengo |
| goby | 受 ruby 啟發,由 go 實現的一種解釋型腳本語言 | https://github.com/goby-lang/goby |
| go+ | 七牛雲開源的腳本語言,可以與 go 無縫交互,又稱 Q 語言 | https://github.com/goplus/gop |
| go-python | go 調用 cpython2 | https://github.com/sbinet/go-python |
| go-pytyon3 | go 調用 cpython3 | https://github.com/DataDog/go-python3 |
圖像處理
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| plot | 一個繪圖庫,多用於數據可視化 | https://github.com/gonum/plot |
| gg | 2d 繪圖庫 | 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 Zanzibar | https://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 |
| pdfcpu | pdf 處理器 | https://github.com/pdfcpu/pdfcpu |
| unioffice | office 處理庫 | https://github.com/unidoc/unioffice |
| gooxml | office 處理庫 | https://github.com/carmel/gooxml |
| pdfcpu | PDF 處理庫 | https://github.com/pdfcpu/pdfcpu |
| excelize | Excel 處理庫 | 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/raft | consul 開源的 raft 庫 | https://github.com/hashicorp/raft |
| hashicorp/memberlist | consul 開源的 gossip 庫 | https://github.com/hashicorp/memberlist |
| etcd-io/raft | etcd 開源的 raft 庫 | https://github.com/etcd-io/raft |
OCR
| 名稱 | 描述 | 倉庫 |
|---|---|---|
| gosseract | 使用 Tesseract C + + 庫的 OCR 庫 | https://github.com/otiai10/gosseract |
