https://www.goproxy.io/docs/GOPRIVATE-env.html
The go command defaults to downloading modules from the public Go module mirror at goproxy.io. It also defaults to validating downloaded modules, regardless of source, against the public Go checksum database at sum.golang.org. These defaults work well for publicly available source code.
The GOPRIVATE environment variable controls which modules the go command considers to be private (not available publicly) and should therefore not use the proxy or checksum database. The variable is a comma-separated list of glob patterns (in the syntax of Go’s path.Match) of module path prefixes. For example,
GOPRIVATE=*.corp.example.com,rsc.io/private <!-- more -->
https://goproxy.io/zh/docs/GOPRIVATE-env.html
若所有需要配置的私有仓库都存在于一个组织下,如 github 下的组织 org_name,则直接填写组织名即可:
GOPRIVATE=github.com/org_name 另外,GOPRIVATE 环境变量可以被其他工具用来识别私有依赖,例如编辑器可以通过 GOPRIVATE 这个变量来决定是否为这个软件包添加一个指向 godoc.org 的文档链接。
https://stackoverflow.com/questions/58305567/how-to-set-goprivate-environment-variable
Short Answer:
go env -w GOPRIVATE=github.com/repoURL/private-repo