Go环境变量在设置后保持不变。

huangapple go评论73阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2017年6月14日 03:54:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/44530376.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定