# go-tutorials **Repository Path**: zhongxc2me/go-tutorials ## Basic Information - **Project Name**: go-tutorials - **Description**: 该项目是golang相关的示例代码,仅供学习 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-21 - **Last Updated**: 2026-03-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Golang Tutorials 该项目包含Golang教程的代码 该存储库仅包含可运行的代码,请查看Golang的相关文档 ### 项目编译 #### windows平台构建Linux平台的目标文件 ``` GOOS=linux GOARCH=amd64 go build -o product-user main.go ``` ### Workspace #### 建立工作区 ``` go work init ``` #### 引入项目 ``` go work use etcd ``` #### 初始化项目模块 ``` go mod init etcd ``` ### 更新所有依赖包 ``` go get -u ``` ### 更新指定依赖包 ``` go get github.com/gin-gonic/gin ``` ### 编译项目(Linux平台) ``` GOOS=linux GOARCH=amd64 go build -o project_user main.go ``` ### 生成rpc项目命令 ``` goctl rpc protoc register.proto --go_out=./types --go-grpc_out=./types --zrpc_out=./register --style go_zero ``` ### 生成api项目命令 ``` goctl api new ucenterapi --style go_zero ``` ### protoc 生成代码 ``` protoc register.proto --go_out=./types --go-grpc_out=./types ``` ### GORM ``` go get -u gorm.io/gorm go get gorm.io/driver/mysql ``` ### 热重载 Go 应用的工具 #### 安装 Air ``` go install github.com/air-verse/air@latest ``` #### 初始化 .air.toml ``` air init ``` #### 运行 Air ``` air .\.air.toml ``` ### Golang中的Go MODULE 和 WorkSpace https://zhuanlan.zhihu.com/p/600283960?utm_id=0 ### gRPC-Go > gRPC的Go实现:一个高性能、开源、通用的 RPC 框架,将移动和 HTTP/2 放在首位。有关更多信息,请参阅 Go gRPC 文档,或直接跳至快速入门。 https://pkg.go.dev/google.golang.org/grpc#section-readme ### gRPC 中的负载均衡 > gRPC 中的负载平衡基于每个调用,而不是每个连接。换句话说,即使所有请求都来自单个客户端,我们仍然希望它们在所有服务器之间实现负载平衡。 https://github.com/grpc/grpc/blob/master/doc/load-balancing.md ### etcd https://github.com/etcd-io/etcd/blob/main/README.md ### etcd命令大全 https://www.orchome.com/620 ### 从零开始搭建etcd分布式存储系统+Web管理界面 https://cloud.tencent.com/developer/article/2057685 ### go-zero目录概述 https://github.com/golang-standards/project-layout/blob/master/README_zh.md ### go-zero微服务实战系列(十一、大结局) https://learnku.com/articles/69991 ### 人机校验 https://www.vaptcha.com/document.install.html ### copier https://github.com/jinzhu/copier ### Air https://github.com/air-verse/air/blob/master/README-zh_cn.md ### protobuf 文档 https://alovn.cn/docs/protobuf/