英文:
Go environment variables stay unchanged after setting
问题
我通过观看在线教程开始学习Go编程。我使用的是Windows命令提示符。然而,在我输入set GOOS = darwin
然后使用go env
打印环境变量时,GOOS
并没有被设置为GOOS=darwin
,而是仍然保持默认值GOOS=windows
。
这是我得到的结果。有人可以告诉我我在哪里出错了,以至于无法更改GOOS
吗?
C:\GoPath\src\palindrome>set GOOS = darwin
C:\GoPath\src\palindrome>go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
英文:
I start learning Go programming by watching online tutorials. I use Windows command prompt. However, after I typed set GOOS = darwin
then used go env
to print environment variables, GOOS
was not set to GOOS=darwin
but still GOOS=windows
as default.
Here is what I got. Could someone tell me where I went wrong such that I cannot make change on GOOS
?
C:\GoPath\src\palindrome>set GOOS = darwin
C:\GoPath\src\palindrome>go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
答案1
得分: 3
“变量名或字符串周围的任何额外空格都不会被忽略,SET 命令不像许多其他脚本语言那样容忍额外的空格。”
将 set GOOS = darwin
改为 set GOOS=darwin
,即与 go env
输出中的格式相同。
英文:
"Any extra spaces around either the variable name or the string, will not be ignored, SET is not forgiving of extra spaces like many other scripting languages."
Change set GOOS = darwin
to set GOOS=darwin
- i.e., the same format you see in the output of go env
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论