英文:
Golang: Getting started - "go" is not recognized as an internal or external command"
问题
尝试开始使用Go,但我无法正确设置工作环境。
英文:
Trying to get started with Go but I cant manage to set up the work environnement properly.
答案1
得分: 12
你将'GOROOT'设置错误了。将其设置为C:\Go\。
将C:\Go\bin添加到你的'Path'中。
英文:
EDITED for future reference.
-
You set your 'GOROOT' wrong. Set it to C:\Go\
-
Include C:\Go\bin to your 'Path'
答案2
得分: 11
除了@Xeph的回答之外,还要确保如果你最近安装了Go语言,你要使用一个新的终端/cmd窗口。
英文:
Aside from @Xeph's answer, just make sure if you recently installed Go that you use a fresh terminal/cmd window.
答案3
得分: 4
运行命令"go env"并检查变量"gopath"的路径,这就是你应该保存项目的地方。否则,如果你运行go命令,你会得到错误信息"go is not recognized as internal or external command"。
英文:
Run command "go env" and check the path for variable "gopath" that's where you should keep your project. Else where if you run go command you will get error "go is not recognized as internal or external command"
答案4
得分: 2
以下是翻译好的内容:
这是让我成功运行的步骤,假设你在 Windows 10 上的全新 GO 安装中没有做任何更改。
- 在用户变量中设置 GOROOT:
C:\Go\
- 在用户变量中添加路径:
%USERPROFILE%\Go\bin
- 在系统变量中添加路径:
C:\Go\bin
英文:
here's what made it work for me, assuming you hadnt change anything from a fresh GO install in windows 10.
- set GOROOT in user variables:
C:\Go\
- add path in user variables:
%USERPROFILE%\Go\bin
- add path in system variables:
C:\Go\bin
答案5
得分: 1
我阅读了各种答案和文章,对我最有帮助的步骤如下:
- 我的电脑 -> 右键点击 -> 属性
- 高级系统设置 -> 环境变量
- 在系统变量部分 -> 新建 -> GOPATH -> 项目位置
- 选择路径 -> 新建 -> 安装的Go的bin目录的路径
- 保存并关闭。
- 重新启动命令提示符/系统。
- 在命令提示符中运行go命令以检查是否正常工作
英文:
I read various answers as well articles and most effective steps that helped me were :
- My Computer -> RC -> Properties
- Advanced System Settings -> Environment Variables
- Under System Variables Section -> New -> GOPATH -> Project Location
- Select Path -> New ->path to bin of installed go
- Save and close.
- Restart the cmd / system .
- Run go in the cmd to check the working .
答案6
得分: 1
如果即使添加了环境变量后仍然无法解决问题,你可以检查是否已经安装了VSCode的Go扩展,如果还没有,请安装它。然后,在工作目录中创建一个新的GO文件,会弹出"gopls命令不可用"的提示,点击"install all"以在VSCode内获得完整支持。我是通过这种方式解决了这个问题,希望能对你有帮助。
英文:
If you are not able to solve the problem even after adding environment variables, you can check if you have installed Go extension from VSCode, install it if you haven't already. Then, when you create a new GO file to work in the working directory, "gopls command not available" will be popped up,click install all to get full support inside VSCode.
I solved the issue like this, I hope that helps.
答案7
得分: 0
你需要将路径变量设置为从C:\Users\YourUser\go
到C:\Users\YourUser\
,然后你就可以在命令行中使用go version
命令查看你的Go版本。
英文:
You need to set path var like from C:\Users\YourUser\go
to C:\Users\YourUser\
then you can see your go version in your command line go version
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论