程序員開(kāi)發(fā)效率神器匯總!
本文作者: neonliu,騰訊 CSIG 開(kāi)發(fā)工程師
neon 是鵝廠的一位資深后臺(tái)開(kāi)發(fā)工程師,多年工作下來(lái)他總結(jié)了很多效率神器,今天分享給大家。
一. 開(kāi)發(fā)工具
1)sql2go
用于將 sql 語(yǔ)句轉(zhuǎn)換為 golang 的 struct. 使用 ddl 語(yǔ)句即可。
例如對(duì)于創(chuàng)建表的語(yǔ)句: show create table xxx. 將輸出的語(yǔ)句,直接粘貼進(jìn)去就行。
http://stming.cn/tool/sql2go.html
2)toml2go
用于將編碼后的 toml 文本轉(zhuǎn)換問(wèn) golang 的 struct.
https://xuri.me/toml-to-go/
3)curl2go
用來(lái)將 curl 命令轉(zhuǎn)化為具體的 golang 代碼.
https://mholt.github.io/curl-to-go/
4)json2go
用于將 json 文本轉(zhuǎn)換為 struct.
https://mholt.github.io/json-to-go/
5)mysql 轉(zhuǎn) ES 工具
http://www.ischoolbar.com/EsParser/
6)golang
模擬模板的工具,在支持泛型之前,可以考慮使用。
https://github.com/cheekybits/genny
7)查看某一個(gè)庫(kù)的依賴情況,類似于 go list 功能
https://github.com/KyleBanks/depth
8)一個(gè)好用的文件壓縮和解壓工具,集成了 zip,tar 等多種功能,主要還有跨平臺(tái)。
https://github.com/mholt/archiver
9)go 內(nèi)置命令
go list 可以查看某一個(gè)包的依賴關(guān)系.
go vet 可以檢查代碼不符合 golang 規(guī)范的地方。
10)熱編譯工具
https://github.com/silenceper/gowatch
11)revive
golang 代碼質(zhì)量檢測(cè)工具
https://github.com/mgechev/revive
12)Go Callvis
golang 的代碼調(diào)用鏈圖工具
https://github.com/TrueFurby/go-callvis
13)Realize
開(kāi)發(fā)流程改進(jìn)工具
https://github.com/oxequa/realize
14)Gotests
自動(dòng)生成測(cè)試用例工具
https://github.com/cweill/gotests
二.調(diào)試工具
1)perf
代理工具,支持內(nèi)存,cpu,堆棧查看,并支持火焰圖.
perf 工具和 go-torch 工具,快捷定位程序問(wèn)題.
https://github.com/uber-archive/go-torch
https://github.com/google/gops
2)dlv 遠(yuǎn)程調(diào)試
基于 goland+dlv 可以實(shí)現(xiàn)遠(yuǎn)程調(diào)式的能力.
https://github.com/go-delve/delve
提供了對(duì) golang 原生的支持,相比 gdb 調(diào)試,簡(jiǎn)單太多。
3)網(wǎng)絡(luò)代理工具
goproxy 代理,支持多種協(xié)議,支持 ssh 穿透和 kcp 協(xié)議.
https://github.com/snail007/goproxy
4)抓包工具
go-sniffer 工具,可擴(kuò)展的抓包工具,可以開(kāi)發(fā)自定義協(xié)議的工具包. 現(xiàn)在只支持了 http,mysql,redis,mongodb.
基于這個(gè)工具,我們開(kāi)發(fā)了 qapp 協(xié)議的抓包。
https://github.com/40t/go-sniffer
5)反向代理工具,快捷開(kāi)放內(nèi)網(wǎng)端口供外部使用。
ngrok 可以讓內(nèi)網(wǎng)服務(wù)外部調(diào)用
https://ngrok.com/
https://github.com/inconshreveable/ngrok
6)配置化生成證書(shū)
從根證書(shū),到業(yè)務(wù)側(cè)證書(shū)一鍵生成.
https://github.com/cloudflare/cfssl
7)免費(fèi)的證書(shū)獲取工具
基于 acme 協(xié)議,從 letsencrypt 生成免費(fèi)的證書(shū),有效期 1 年,可自動(dòng)續(xù)期。
https://github.com/Neilpang/acme.sh
8)開(kāi)發(fā)環(huán)境管理工具,單機(jī)搭建可移植工具的利器。支持多種虛擬機(jī)后端。
vagrant常被拿來(lái)同 docker 相比,值得擁有。
https://github.com/hashicorp/vagrant
9)輕量級(jí)容器調(diào)度工具
nomad 可以非常方便的管理容器和傳統(tǒng)應(yīng)用,相比 k8s 來(lái)說(shuō),簡(jiǎn)單不要太多.
https://github.com/hashicorp/nomad
10)敏感信息和密鑰管理工具
https://github.com/hashicorp/vault
11)高度可配置化的 http 轉(zhuǎn)發(fā)工具,基于 etcd 配置。
https://github.com/gojek/weaver
12)進(jìn)程監(jiān)控工具 supervisor
https://www.jianshu.com/p/39b476e808d8
13)基于 procFile 進(jìn)程管理工具. 相比 supervisor 更加簡(jiǎn)單。
https://github.com/ddollar/foreman
14)基于 http,https,websocket 的 調(diào)試代理工具 ,配置功能豐富。在線教育的 nohost web 調(diào)試工具,基于此開(kāi)發(fā).
https://github.com/avwo/whistle
15)分布式調(diào)度工具
https://github.com/shunfei/cronsun/blob/master/README_ZH.md
https://github.com/ouqiang/gocron
16)自動(dòng)化運(yùn)維平臺(tái) Gaia
https://github.com/gaia-pipeline/gaia
三. 網(wǎng)絡(luò)工具
四. 常用網(wǎng)站
go 百科全書(shū): https://awesome-go.com/
json 解析: https://www.json.cn/
出口 IP: https://ipinfo.io/
redis 命令: http://doc.redisfans.com/
ES 命令首頁(yè):
https:/ /w ww.elasti c.co/guide/cn/elasticsearch/guide/current/index.html
UrlEncode: http://tool.chinaz.com/Tools/urlencode.aspx
Base64: https://tool.oschina.net/encrypt?type=3
Guid: https://www.guidgen.com/
常用工具: http://www.ofmonkey.com/
五. golang 常用庫(kù)
日志
https://github.com/Sirupsen/logrus
https://github.com/uber-go/zap
配置
兼容 json,toml,yaml,hcl 等格式的日志庫(kù).
https://github.com/spf13/viper
存儲(chǔ)
mysql: https://github.com/go-xorm/xorm
es: https://github.com/elastic/elasticsearch
redis: https://github.com/gomodule/redigo
mongo: https://github.com/mongodb/mongo-go-driver
kafka: https://github.com/Shopify/sarama
數(shù)據(jù)結(jié)構(gòu)
https://github.com/emirpasic/gods
命令行
https://github.com/spf13/cobra
框架
https://github.com/grpc/grpc-go
https://github.com/gin-gonic/gin
并發(fā)
https://github.com/Jeffail/tunny
https://github.com/benmanns/goworker
現(xiàn)在我們框架在用的,雖然 star 不多,但是確實(shí)好用,當(dāng)然還可以更好用.
https://github.com/rafaeldias/async
工具
定義了實(shí)用的判定類,以及針對(duì)結(jié)構(gòu)體的校驗(yàn)邏輯,避免業(yè)務(wù)側(cè)寫(xiě)復(fù)雜的代碼.
https://github.com/asaskevich/govalidator
https://github.com/bytedance/go-tagexpr
protobuf 文件動(dòng)態(tài)解析的接口,可以實(shí)現(xiàn)反射相關(guān)的能力。
https://github.com/jhump/protoreflect
表達(dá)式引擎工具
https://github.com/Knetic/govaluate
https://github.com/google/cel-go
字符串處理
https://github.com/huandu/xstrings
ratelimit 工具
https://github.com/uber-go/ratelimit
https://blog.csdn.net/chenchongg/article/details/85342086
https://github.com/juju/ratelimit
golang 熔斷的庫(kù)
熔斷除了考慮頻率限制,還要考慮 qps,出錯(cuò)率等其他東西.
https://github.com/afex/hystrix-go
https://github.com/sony/gobreaker
表格
https://github.com/chenjiandongx/go-echarts
tail 工具庫(kù)
https://github.com/hpcloud/taglshi