bash Git Shell - 找不到 go 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36869660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 14:33:24  来源:igfitidea点击:

Git Shell - go command not found

gitbashshellcommand

提问by Martin Schmidt

I found this course on a website called Lynda.com (some of you probably know about this website).

我在一个名为 Lynda.com 的网站上找到了这门课程(你们中的一些人可能知道这个网站)。

The course was called: Code Clinic: Go. So, I'm using something called Goor Golangand I downloaded this command program called Git Shell, and whenever I execute a Go Command, I get this message:

课程名称为:Code Clinic: Go。所以,我使用了一个叫做Goor 的东西Golang,我下载了这个叫做 的命令程序Git Shell,每当我执行 Go 命令时,我都会收到这条消息:

bash: go : command not found

Does anybody know what's going on?

有人知道这是怎么回事吗?

回答by whyzhi

You have to put the Go executable in your PATH:

你必须把 Go 可执行文件放在你的 PATH 中:

1) cd ~

1) cd ~

2) vi .bashrc

2) vi .bashrc

3) Inside .bashrc, enter the following: PATH=$PATH:/c/Go/bin

3) 在 .bashrc 中,输入以下内容: PATH=$PATH:/c/Go/bin

Restart git bash and you should now have the gocommand

重新启动 git bash,您现在应该拥有go命令

回答by Prosp

You need to set GOPATH environment variable with the path of your GO installation directory.

您需要使用 GO 安装目录的路径设置 GOPATH 环境变量。

For example if your Go installation directory is C:\Go

例如如果你的 Go 安装目录是 C:\Go

Open a bash terminal and run the following:

打开 bash 终端并运行以下命令:

GOPATH=/c/Go/bin

Then type go versionto check if it works

然后输入go version以检查它是否有效

you should see the go version you installed

你应该看到你安装的 go 版本

回答by Charles Duffy

The Go compiler is not part of Git Bash; you need to install it separately.

Go 编译器不是 Git Bash 的一部分;您需要单独安装它。

See the download page on http://golang.org/; for Windows, one of the MSI installers is most likely to be appropriate.

请参阅http://golang.org/上的下载页面;对于 Windows,MSI 安装程序之一最有可能是合适的。

回答by Fawaz Abdulla

It seems the issue is with environment variables. You can get a quick and easy fix by running Go installer then choose 'repair' from the installation options.

似乎问题出在环境变量上。您可以通过运行 Go 安装程序获得快速简单的修复,然后从安装选项中选择“修复”。