首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用特定的环境值运行go get命令?

如何使用特定的环境值运行go get命令?
EN

Stack Overflow用户
提问于 2021-12-14 10:13:12
回答 1查看 644关注 0票数 2

我想在GOPROXY='direct'时运行go get命令,我尝试使用VS代码终端运行这个命令:

代码语言:javascript
复制
GOPROXY='direct' go get go.mongodb.org/mongo-driver/mongo

但我发现了一个错误:

代码语言:javascript
复制
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

我也试过:

代码语言:javascript
复制
go env set GOPROXY='direct'

但是,当我运行go env命令时,GOPROXY值仍然与这个GOPROXY=https://proxy.golang.org,direct类似,我还试图在windows环境变量中定义一个GOPROXY变量,并给它direct的值,但它也做不到这一点。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-15 08:27:17

确保您的VSCode终端是bash终端,而不是CMD或Powershell。

在CMD或Powershell中,语法var=xxx cmd不能正确解释为:设置变量并执行继承其环境变量(包括一个集合)的命令。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70347135

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档