环境、工具链与模块化
先把开发环境、编辑器、模块依赖和命令行工作流搭稳,避免还没写业务就被路径和依赖绊住。
阶段目标:能独立创建模块、运行测试、安装工具、管理多模块 workspace。
安装与编辑器
- 安装当前稳定版 Go,使用 go version 验证。
- VS Code + Go 插件 + gopls + dlv,或 GoLand。
- 理解 GOROOT、GOPATH、GOBIN、PATH 的角色。
Go Modules
- go mod init、go get、go mod tidy、go list -m -u all。
- 理解 go.mod、go.sum、语义化版本与 module path。
- 国内环境配置 GOPROXY,私有仓库配置 GOPRIVATE。
工作区与工具
- go work init/use 管理多模块联调。
- go fmt、go test、go test -race、go vet、go install。
- 建立 Makefile 或 taskfile,固化常用命令。
go env -w GOPROXY=https://goproxy.cn,direct
mkdir hello-api && cd hello-api
go mod init example.com/hello-api
go test ./...

