如何 运行 具有特定环境值的 go get 命令?
how to run a go get command with certain environment values?
我想 运行 在 GOPROXY='direct'
时执行一个 go get 命令,我已经尝试 运行 使用 VS 代码终端执行此命令:
GOPROXY='direct' go get go.mongodb.org/mongo-driver/mongo
但我收到此错误:
GOPROXY=direct : The term 'GOPROXY=direct' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ GOPROXY='direct' go get go.mongodb.org/mongo-driver/mongo
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (GOPROXY=direct:String) [], CommandNotFoundEx
ception
+ FullyQualifiedErrorId : CommandNotFoundException
我也试过:
go env set GOPROXY='direct'
但是当我 运行 go env
命令时 GOPROXY
值仍然是这样 GOPROXY=https://proxy.golang.org,direct
我还尝试在 windows 环境变量中定义一个 GOPROXY 变量并赋予它 direct
的值,但它也未能完成这项工作。
确保您的 VSCode 终端是 bash
终端,而不是 CMD 或 Powershell。
在 CMD 或 Powershell 中,语法 var=xxx cmd
不会被正确解释为:设置变量并执行继承其环境变量的命令,包括一组。
我想 运行 在 GOPROXY='direct'
时执行一个 go get 命令,我已经尝试 运行 使用 VS 代码终端执行此命令:
GOPROXY='direct' go get go.mongodb.org/mongo-driver/mongo
但我收到此错误:
GOPROXY=direct : The term 'GOPROXY=direct' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ GOPROXY='direct' go get go.mongodb.org/mongo-driver/mongo
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (GOPROXY=direct:String) [], CommandNotFoundEx
ception
+ FullyQualifiedErrorId : CommandNotFoundException
我也试过:
go env set GOPROXY='direct'
但是当我 运行 go env
命令时 GOPROXY
值仍然是这样 GOPROXY=https://proxy.golang.org,direct
我还尝试在 windows 环境变量中定义一个 GOPROXY 变量并赋予它 direct
的值,但它也未能完成这项工作。
确保您的 VSCode 终端是 bash
终端,而不是 CMD 或 Powershell。
在 CMD 或 Powershell 中,语法 var=xxx cmd
不会被正确解释为:设置变量并执行继承其环境变量的命令,包括一组。