在Debian系统提升Golang编译性能可从以下方面入手:
-c 只编译不链接,-s 去除调试信息,-parallel n 设置并行编译任务数(如 -parallel 4)。-buildcache true 或设置 GOCACHE 环境变量指定缓存目录。GOPROXY=https://goproxy.cn)加速依赖下载。go mod vendor 将依赖存入本地 vendor 目录,避免重复下载。GOMAXPROCS 等于 CPU 核心数,充分利用多核资源。CGO_ENABLED=0 关闭(纯 Go 代码编译更快)。Gazelle 等工具优化依赖关系,pprof 分析性能瓶颈。-ldflags 去除符号表(-s)和警告(-w),减小二进制体积。