# Go
# Flag
- https://github.com/golang (opens new window)
- https://github.com/pkg (opens new window)
- https://go.dev (opens new window)
- https://github.com/golangclub/golangcn.org (opens new window)
- https://github.com/studygolang (opens new window)
- 在JVM中运行 https://github.com/zxh0/jvm.go (opens new window)
- 分布式跟踪后端 https://github.com/grafana/tempo (opens new window)
- 监视和配置网络设备的工具 https://github.com/inexio/thola (opens new window)
- https://github.com/dominikh/go-tools (opens new window)
- json生成go数据结构 https://github.com/misakafs/json-to-go (opens new window)
- 【Golang】实现文件服务器断点续传 (opens new window)
- Go实现HTTP断点续传多线程下载 (opens new window)
- https://github.com/hwholiday/file_storage (opens new window)
- Golang信号处理和优雅退出守护进程 (opens new window)
Windows下可以安装MinGW-w64、MSYS2、Cygwin以调用GCC,Windows10下推荐使用WSL
插件化开发
# 学习
- go文档中文翻译 https://github.com/polaris1119/pkgdoc (opens new window)
- Go 语言文档中文翻译 (opens new window)
- Go 标准库中文文档 (opens new window)
- https://github.com/taigacute/GoDoc-CN (opens new window)
- https://github.com/golang-china/gopl-zh (opens new window)
- Go 语言中文开源图书、资料或文档 (opens new window)
- Go 开发者路线图 (opens new window)
- Go 学习之路 (opens new window)
- Go基本类型说明 (opens new window)
- Go语言小册 (opens new window)
- 模板语法指南 (opens new window)
- golang 学习笔记 (opens new window)
- https://doc.xuwenliang.com/docs/go (opens new window)
- Go 语言编程 (opens new window) - Golang电子书介绍如何使用Golang建立网络
- 《The Way to Go》中文译本,中文正式名《Go 入门指南 (opens new window)》
- 《Go 编程基础 (opens new window)》是一套针对Go语言的视频语音教程,主要面向新手级别的学习者。
- 第三方类库 (opens new window)
- Go 官方文档翻译 (opens new window)
- Go 指南 (opens new window)
- Go 简易教程 (opens new window)
- Go 语言实战笔记 (opens new window)
- Go 语言标准库 (opens new window)
- Go 语言高级编程(Advanced Go Programming) (opens new window)
- Go命令教程 (opens new window)
- Go实战开发 (opens new window)
- Go语言博客实践 (opens new window)
- Java程序员的Golang入门指南 (opens new window)
- Network programming with Go 中文翻译版本 (opens new window)
- Revel 框架手册 (opens new window)
- 学习Go语言 (opens new window)
- 神奇的 Go 语言 (opens new window)
- https://github.com/TiantianUpup/go-study (opens new window)
- Go 语言 Web 应用开发系列教程 (opens new window)
- https://github.com/rubyhan1314/Golang-100-Days (opens new window)
- Go 编程实例 Go by Example (opens new window)
- https://github.com/lexkong/apiserver_demos (opens new window)
- https://github.com/jiujuan/go-collection (opens new window)
- 中文学习资料 https://github.com/gwuhaolin/golang-book (opens new window)
- 设计模式 https://github.com/tmrts/go-patterns (opens new window)
- https://github.com/0voice/Introduction-to-Golang (opens new window)
- https://github.com/golang-design (opens new window)
- https://github.com/cch123/golang-notes (opens new window)
- https://github.com/shgopher/GOFamily (opens new window)
- https://github.com/pibigstar/go-demo (opens new window)
- https://www.topgoer.com (opens new window)
- https://github.com/iswbm (opens new window)
- Go语法树入门 https://github.com/chai2010/go-ast-book (opens new window)
- https://github.com/halfrost/LeetCode-Go (opens new window)
- Go泛型入门 https://github.com/akutz/go-generics-the-hard-way (opens new window)
- 周刊 https://github.com/polaris1119/golangweekly (opens new window)
- https://gobyexample.com (opens new window)
- https://golang3.eddycjy.com (opens new window)
- https://draveness.me/golang (opens new window)
- https://talkgo.org (opens new window)
- https://github.com/golang101/golang101 (opens new window)
- https://github.com/yongxinz/gopher (opens new window)
- https://github.com/gocn (opens new window)
- 日报 https://github.com/bigwhite/gopherdaily (opens new window)
- Go子语言 https://github.com/chai2010/ugo-compiler-book (opens new window)
- https://github.com/wa-lang/wa (opens new window)
- Go_想变厉害的大白菜的博客-CSDN博客 (opens new window)
- Go的隐秘世界:Goroutine调度机制概览 (opens new window)
- golang调度学习-调度流程 (opens new window)
- 系统调用,ptrace,go语言syscall (opens new window)
# 第三方库
- https://github.com/avelino/awesome-go (opens new window)
- https://github.com/yinggaozhen/awesome-go-cn (opens new window)
- web框架基准测试 https://github.com/smallnest/go-web-framework-benchmark (opens new window)
- 序列化工具基准测试 https://github.com/smallnest/gosercomp (opens new window)
- 压测工具 https://github.com/link1st/go-stress-testing (opens new window)
- 监控运行 https://github.com/thejerf/suture (opens new window)
- https://github.com/PagerDuty (opens new window)
框架 | GitHub | 官网 |
---|---|---|
gin | https://github.com/gin-gonic/gin https://github.com/gin-contrib | https://gin-gonic.com |
echo | https://github.com/labstack/echo | https://echo.labstack.com http://go-echo.org |
GoFrame | https://github.com/gogf/gf | https://goframe.org |
iris | https://github.com/kataras/iris | https://iris-go.com https://studyiris.com |
grbac | https://github.com/storyicon/grbac | |
gin-jwt | https://github.com/appleboy/gin-jwt | |
kit | https://github.com/go-kit/kit | https://gokit.io |
Fiber | https://github.com/gofiber/fiber | https://gofiber.io |
revel | https://github.com/revel/revel | https://github.com/revel/revel |
- https://github.com/vishvananda/netlink (opens new window)
- https://github.com/go-martini/martini (opens new window)
- https://github.com/xyproto/algernon (opens new window)
- https://github.com/urfave (opens new window)
- 分布式 https://github.com/asim/go-micro (opens new window)
- https://github.com/gotomicro (opens new window)
- https://github.com/go-playground (opens new window)
- https://github.com/modern-go (opens new window)
- https://github.com/urfave (opens new window)
- https://github.com/spf13 (opens new window)
- https://github.com/nanopack (opens new window)
- https://github.com/go-logr (opens new window)
- https://github.com/apex (opens new window)
- https://github.com/gorilla (opens new window)
- https://github.com/eolinker (opens new window)
- 数据库驱动 https://github.com/go-sql-driver (opens new window)
- https://github.com/hashicorp (opens new window)
- https://github.com/boombuler (opens new window)
- https://github.com/goplus (opens new window)
- https://github.com/gliderlabs (opens new window)
- https://github.com/mailru (opens new window)
- https://github.com/mholt (opens new window)
- https://github.com/moul (opens new window)
- https://github.com/frobware (opens new window)
- https://github.com/juju (opens new window)
工具包 https://github.com/dablelv/go-huge-util (opens new window)
https://github.com/julienschmidt/httprouter (opens new window)
https://github.com/Andrew-M-C/go.jsonvalue (opens new window)
JSON转CSV https://github.com/yukithm/json2csv (opens new window)
反射库高级抽象 https://github.com/oleiade/reflections (opens new window)
模板功能 https://github.com/Masterminds/sprig (opens new window)
https://github.com/open-falcon/mail-provider (opens new window)
https://github.com/beanstalkd/go-beanstalk (opens new window)
快速生成ASCII表格 https://github.com/olekukonko/tablewriter (opens new window)
获取固定宽度的字符或字符串 https://github.com/mattn/go-runewidth (opens new window)
具有历史记录的命令行编辑器 https://github.com/peterh/liner (opens new window)
自动控制基于终端或控制台 https://github.com/Netflix/go-expect (opens new window)
任务排队系统 https://git.sr.ht/~sircmpwn/dowork (opens new window)
对图像序列(例如延时拍摄)进行闪烁处理 https://github.com/StruffelProductions/simple-deflicker (opens new window)
控制台进度条显示 https://github.com/vardius/progress-go (opens new window)
计算文件的SHA256 https://github.com/benbjohnson/hashfs (opens new window)
模板引擎 https://github.com/valyala/quicktemplate (opens new window)
AES256 GCM https://github.com/sumup-oss/vaulted (opens new window)
Golang注解 https://github.com/MarcGrol/golangAnnotations (opens new window)
https://github.com/refraction-networking/utls (opens new window)
十进制数 https://github.com/shopspring/decimal (opens new window)
excel https://github.com/360EntSecGroup-Skylar/excelize (opens new window)
Quoted-printable https://github.com/sloonz/go-qprintable (opens new window)
WebSocket https://github.com/gorilla/websocket (opens new window)
https://github.com/hekmon/transmissionrpc (opens new window)
基于WebRTC的分布式音频/视频室 https://github.com/livekit/livekit-server (opens new window)
结构转换 https://github.com/mitchellh/mapstructure (opens new window)
https://github.com/seccomp/libseccomp-golang (opens new window)
https://github.com/charmbracelet/bubbletea (opens new window)
内核模糊器 https://github.com/google/syzkaller (opens new window)
Markdown处理 https://github.com/russross/blackfriday (opens new window)
markdown转roff https://github.com/cpuguy83/go-md2man (opens new window)
媒体类型 http://github.com/gabriel-vasile/mimetype (opens new window)
图片转换 https://github.com/gographics/imagick (opens new window)
限速 https://github.com/Narasimha1997/ratelimiter (opens new window)
https://github.com/kelseyhightower/envconfig (opens new window)
文件监听 https://github.com/fsnotify/fsnotify (opens new window)
监视文件或目录更改 https://github.com/radovskyb/watcher (opens new window)
通道工具 https://github.com/Ksloveyuan/channelx (opens new window)
配置加载 [https://github.com/cristalhq/aconfig](https://github.com/cristalhq/aconfig
分布式唯一ID https://github.com/yongxinz/id-maker (opens new window)
单元测试 https://github.com/maxbrunsfeld/counterfeiter (opens new window)
替换DOCX中的文本 https://github.com/nguyenthenguyen/docx (opens new window)
- 实时视频流服务器 https://github.com/gwuhaolin/livego (opens new window)
- IP代理池 https://github.com/henson/proxypool (opens new window)
- https://github.com/3xxx/engineercms (opens new window)
- https://github.com/flipped-aurora/gin-vue-admin (opens new window)
- https://github.com/go-admin-team/go-admin (opens new window)
- https://github.com/LyricTian/gin-admin (opens new window)
- https://github.com/hzwy23/hauth (opens new window)
# 工具链
- 安装最新go https://github.com/golang/tools/tree/master/cmd/getgo (opens new window)
- go版本管理 https://github.com/stefanmaric/g (opens new window)
- https://github.com/voidint/g (opens new window)
- https://github.com/moovweb/gvm (opens new window)
- https://github.com/syndbg/goenv (opens new window)
- 调试器 https://github.com/go-delve/delve (opens new window)
- 实时重新加载 https://github.com/cosmtrek/air (opens new window)
- https://github.com/gravityblast/fresh (opens new window)
- https://github.com/beego/bee (opens new window)
- https://github.com/silenceper/gowatch (opens new window)
- https://github.com/codegangsta/gin (opens new window)
- https://github.com/oxequa/realize (opens new window)
- 深入理解Go之generate (opens new window)
- https://github.com/gohouse/converter (opens new window)
- https://github.com/Zhwt/yaml-to-go (opens new window)
- 正则在线测试 http://regoio.herokuapp.com (opens new window)
- 接口和结构体UML https://www.dumels.com (opens new window)
- 测试文件中单个函数
go test -v 文件名_test.go -test.run 函数名
# 直接指定函数不指定文件运行
go test -v -test.run 函数名
关键点 | 说明 |
---|---|
导入需要的包 | import testing (如果你是goland,那么可以忽略,因为ide就自动帮你加上) |
执行命令 | go test file_test.go |
测试文件命名 | 必须以_test.go结尾 |
功能测试的用力函数 | 必须以Test开头&&后头跟着的函数名不能以小写字母开头,比如:Testcbs 就是不行的,TestCbs就是ok的 |
功能测试参数 | testing.T |
压力测试用例函数 | 必须以Benchmark开头&&其后的函数名不能以小写字母开头(例子同上) |
压力测试参数 | testing.B |
测试信息 | .Log方法,默认情况下是不会显示的,只有在go test -v的时候显示 |
测试控制 | 通过Error/Errorf/FailNow/Fatal等来进行测试是否是失败,或者在失败的情况下的控制 |
压力测试命令 | go test -test.bench file_test.go |
压力测试的循环体 | 使用test.B.N |
# Modules
命令 | 说明 |
---|---|
go mod init | initialize new module in current directory(在当前目录初始化mod) |
go mod download | download modules to local cache(下载依赖包) |
go mod edit | edit go.mod from tools or scripts(编辑go.mod |
go mod graph | print module requirement graph (打印模块依赖图) |
go mod tidy | add missing and remove unused modules(拉取缺少的模块,移除不用的模块) |
go mod vendor | make vendored copy of dependencies(将依赖复制到vendor下) |
go mod verify | verify dependencies have expected content (验证依赖是否正确) |
go mod why | explain why packages or modules are needed(解释为什么需要依赖) |
- 查看所有可升级依赖版本
go list -u -m all
添加依赖
- 添加依赖:
go get github.com/xxx/xxx
- 添加指定版本:
go get github.com/xxx/xxx@v1.6.2
- 添加指定版本范围:
go get github.com/xxxx/xxx@'<v1.6.2'
- 添加指定
commit
的版本:go get github.com/xxxx/xxx@q2516faf3
升级依赖
- 升级
Major
:go get -u github.com/xxx/xxx
- 升级全部依赖的
Minor
或PATCH
版本:go get -u
- 升级全部依赖的
PATCH
版本:go get -u=patch
# Modules代理
查看Go的环境信息
go env
GOPROXY
GO 1.13
版本开始GOPROXY
支持多代理设置,通过,
隔开
- 通用
go env -w GOPROXY=https://goproxy.io,https://goproxy.cn,direct
- Linux
export GOPROXY=https://goproxy.io,https://goproxy.cn,direct
- Windows
setx /m GOPROXY "https://goproxy.io,https://goproxy.cn,direct"
当第一个
proxy
在处理ge get
所发出的HTTP
请求时,返回HTTP
状态码为404
或410
时,就会查找下一个proxy
GOPRIVATE
设置
GOPRIVATE
来跳过私有库,比如常用的Github
、Gitlab
、Gitee
,中间使用,
分隔
go env -w GOPRIVATE=*.github.com,*.gitlab.com,*.gitee.com
GOSUMDB
如果在运行
go mod vendor
时,提示Get https://sum.golang.org/lookup/xxxxxx: dial tcp 216.58.200.49:443: i/o timeout
, 则是因为Go 1.13
设置了默认的GOSUMDB=sum.golang.org
,这个网站是被墙了的,用于验证包的有效性,可以通过如下命令关闭
go env -w GOSUMDB=off
- https://mirrors.aliyun.com/goproxy (opens new window)
- https://mirrors.cloud.tencent.com/help/go.html (opens new window)
- https://github.com/goproxy (opens new window)
- https://github.com/goproxyio (opens new window)
- https://github.com/gomods/athens (opens new window)
- https://github.com/jfrog/gocenter (opens new window)
GoGUI →