# Go
# Flag
- https://github.com/golang (opens new window)
- https://github.com/pkg (opens new window)
- https://go.dev (opens new window)
- https://golang.google.cn/dl (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)
- https://github.com/studygolang (opens new window)
- 在JVM中运行 https://github.com/zxh0/jvm.go (opens new window)
- 【Golang】实现文件服务器断点续传 (opens new window)
- Go实现HTTP断点续传多线程下载 (opens new window)
- https://github.com/hwholiday/file_storage (opens new window)
插件化开发
Rust
- https://github.com/rust-lang (opens new window)
- http://www.rust-lang.org (opens new window)
- http://doc.rust-lang.org (opens new window)
- Rust - 花落花开 (opens new window)
- https://budshome.com (opens new window)
- https://github.com/mesalock-linux/mesalink (opens new window)
- https://github.com/ctz/rustls (opens new window)
- https://github.com/briansmith/webpki (opens new window)
- https://github.com/briansmith/ring (opens new window)
C/C++
- https://github.com/ocornut/imgui (opens new window)
- https://github.com/FlaxEngine/FlaxEngine (opens new window)
- 树莓派 https://github.com/raspberrypi (opens new window)
- 包管理 https://github.com/microsoft/vcpkg (opens new window)
- https://github.com/conan-io/conan (opens new window)
# 第三方库
- https://github.com/avelino/awesome-go (opens new window)
- https://github.com/yinggaozhen/awesome-go-cn (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 |
- https://github.com/giampaolo/psutil (opens new window)
- https://github.com/shirou/gopsutil (opens new window)
- JSON解析器 https://github.com/json-iterator (opens new window)
- https://github.com/deckarep/golang-set (opens new window)
- https://github.com/chenhg5/collection (opens new window)
- 线程池 工作池 https://github.com/xxjwxc/gowp (opens new window)
- 模板功能 https://github.com/Masterminds/sprig (opens new window)
- 分布式关系型数据库 https://github.com/pingcap/tidb (opens new window)
- https://github.com/flike/kingshard (opens new window)
- https://github.com/open-falcon (opens new window)
- https://github.com/open-falcon/mail-provider (opens new window)
- https://github.com/Yanjunhui/chat (opens new window)
- 定时任务 https://github.com/ouqiang/gocron (opens new window)
- https://github.com/robfig/cron (opens new window)
- https://github.com/jasonlvhit/gocron (opens new window)
- https://github.com/ouqiang/delay-queue (opens new window)
- https://github.com/go-xorm (opens new window)
- https://github.com/libragen/felix (opens new window)
- https://github.com/spf13/viper (opens new window)
- https://github.com/eventials/go-tus (opens new window)
- 对象存储 https://github.com/minio/minio (opens new window)
- https://github.com/sjqzhang/go-fastdfs (opens new window)
- 监视文件或目录更改 https://github.com/radovskyb/watcher (opens new window)
- 快速生成ASCII表格 https://github.com/olekukonko/tablewriter (opens new window)
- 获取固定宽度的字符或字符串 https://github.com/mattn/go-runewidth (opens new window)
- Lane包提供队列,优先级队列,堆栈和双端队列 https://github.com/oleiade/lane (opens new window)
- 具有历史记录的命令行编辑器 https://github.com/peterh/liner (opens new window)
- 自动控制基于终端或控制台 https://github.com/Netflix/go-expect (opens new window)
- https://github.com/google/goexpect (opens new window)
- https://github.com/google/goterm (opens new window)
- https://github.com/ThomasRooney/gexpect (opens new window)
- https://github.com/mattn/go-sqlite3 (opens new window)
- Swagger 2.0 for Go https://github.com/swaggo (opens new window)
- https://github.com/owenliang/go-push (opens new window)
- https://github.com/rs/zerolog (opens new window)
- https://github.com/uber-go/zap (opens new window)
- https://github.com/apex/log (opens new window)
- https://xorm.io (opens new window)
- HTTP实现 https://github.com/valyala/fasthttp (opens new window)
- https://github.com/parnurzeal/gorequest (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)
← Go编译打包 WindowsGCC →