~/.bashrc或~/.zshrc文件,配置GOROOT(Go安装路径,如/usr/local/go)、GOPATH(工作空间,如$HOME/go)和PATH(添加$GOROOT/bin和$GOPATH/bin),运行source ~/.bashrc使更改生效,确保全局可执行Go命令。go mod init <module-name>初始化项目模块,替代传统的GOPATH模式,解决依赖版本冲突问题;使用go get -v <package>添加依赖,go mod tidy清理未使用的依赖。gvm(Go Version Manager),通过bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)安装,再用gvm install <version>和gvm use <version>管理版本。gofmt:自动格式化代码(如gofmt -l -s yourfile.go,-l显示需格式化的文件,-s简化代码);go vet:检查代码潜在问题(如错误的Printf格式、未使用的变量);go build/go run:快速编译(go build生成可执行文件)或运行(go run直接执行)代码。go <function>()启动轻量级协程(Goroutine),通过channel实现协程间通信(如ch := make(chan int)),避免共享内存带来的竞态问题。sync.Mutex(互斥锁)或sync.RWMutex(读写锁)保护共享资源(如全局变量),使用sync.WaitGroup等待多个Goroutine完成(如wg.Add(1)、wg.Done()、wg.Wait())。sync.Pool复用临时对象(如pool := &sync.Pool{New: func() interface{} { return make([]byte, 1024) }}),避免频繁内存分配和垃圾回收;预分配缓冲区(如buf := make([]byte, 1024)),减少动态扩容的开销。"runtime/pprof",通过f, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f); defer pprof.StopCPUProfile()开启CPU分析,使用go tool pprof cpu.prof生成可视化报告,定位CPU热点(如循环、递归)。go build -i安装依赖(跳过测试),加快后续编译速度;使用go build -a强制重新编译所有包(解决依赖更新问题);使用go test -c预编译测试二进制文件(如go test -c -o mytest.test),加快测试执行速度。-ldflags="-s -w"去除调试信息和符号表(减小二进制文件大小,如go build -ldflags="-s -w" main.go);使用-race启用数据竞争检测(如go run -race main.go),发现并发中的潜在问题。gofmt统一代码格式(如缩进、括号位置);命名遵循“简洁明了”原则(如函数名用GetUser而非getUserInfo),变量名用驼峰式(如userName);错误处理使用if err != nil模式(如file, err := os.Open("test.txt"); if err != nil { log.Fatal(err) })。package划分功能模块(如package main为入口包,package utils为工具包),遵循“单一职责”原则(每个函数/包只做一件事);编写单元测试(如func TestAdd(t *testing.T)),使用go test运行测试(覆盖率达80%以上)。git init),添加远程仓库(git remote add origin <repository-url>),使用git add、git commit、git push提交和推送代码;学习高级功能(如git branch分支管理、git merge合并冲突、git rebase变基),确保代码版本可控。Makefile定义常用命令(如build: go build -o app main.go、test: go test ./...、clean: rm -f app),通过make build、make test快速执行任务,减少重复输入。docker build -t myapp . && docker push myapp),提高交付效率。