英文:
Trouble with Go
问题
我昨晚决定下载go并看看它是怎么回事。问题是,我无法让这个该死的东西正常工作。我下载了程序,创建了一个工作空间,尝试使用go install
命令,但什么都没有发生。我的工作空间位于C:\go\src\gocode
,里面有我的hello.go
文件。我尝试手动设置GOPATH变量为这个位置,使用命令setx GOPATH C:\go\src\gocode
,但没有成功。有人可以指点我正确的方向吗?
英文:
I decided to download go last night and see what it was all about. Trouble is, I can't get the damn thing to function. I downloaded the program, created a workspace, tried using the go install
command, and nothing. I have my workspace located at C:\go\src\gocode
in which is my hello.go
file. I tried manually setting the GOPATH variable to this location via setx GOPATH C:\go\src\gocode
, but no luck. Can anyone possibly point me in the right direction?
答案1
得分: 4
Go项目为Windows用户提供了两种安装选项(除了从源代码安装):一个需要设置一些环境变量的zip归档文件,以及一个自动配置安装的MSI安装程序。
MSI安装程序:
打开MSI文件(https://code.google.com/p/go/wiki/Downloads?tm=2),按照提示安装Go工具。默认情况下,安装程序将Go发行版放在c:\Go目录中。
安装程序应该将c:\Go\bin目录添加到您的PATH环境变量中。您可能需要重新启动任何打开的命令提示符以使更改生效。
Zip归档文件:
下载zip文件(https://code.google.com/p/go/wiki/Downloads?tm=2),并将其解压到您选择的目录中(我们建议c:\Go)。
如果您选择的目录不是c:\Go,则必须将GOROOT环境变量设置为您选择的路径。
将Go根目录的bin子目录(例如c:\Go\bin)添加到您的PATH环境变量中。
在Windows下设置环境变量:
在Windows下,您可以通过“系统”控制面板的“高级”选项卡上的“环境变量”按钮来设置环境变量。某些Windows版本通过“系统”控制面板内的“高级系统设置”选项提供此控制面板。
英文:
> The Go project provides two installation options for Windows users
> (besides installing from source): a zip archive that requires you to
> set some environment variables and an MSI installer that configures
> your installation automatically.
>
> MSI installer
>
> Open the MSI file(https://code.google.com/p/go/wiki/Downloads?tm=2)
> and follow the prompts to install the Go tools. By default, the
> installer puts the Go distribution in c:\Go.
>
> The installer should put the c:\Go\bin directory in your PATH
> environment variable. You may need to restart any open command prompts
> for the change to take effect.
>
> Zip archive
>
> Download the zip(https://code.google.com/p/go/wiki/Downloads?tm=2)
> file and extract it into the directory of your choice (we suggest
> c:\Go).
>
> If you chose a directory other than c:\Go, you must set the GOROOT
> environment variable to your chosen path.
>
> Add the bin subdirectory of your Go root (for example, c:\Go\bin) to
> your PATH environment variable.
>
> Setting environment variables under Windows
>
> Under Windows, you may set environment variables through the
> "Environment Variables" button on the "Advanced" tab of the "System"
> control panel. Some versions of Windows provide this control panel
> through the "Advanced System Settings" option inside the "System"
> control panel.
This is from : http://golang.org/doc/install
答案2
得分: 3
安装Go语言的快速方法是使用MSI安装程序。安装程序只会将C:\Go\bin
目录添加到你的PATH
环境变量中,你需要在环境设置中手动设置GOPATH
。
根据Go语言官方网站的说明:
>在Windows下,你可以通过“系统”控制面板的“高级”选项卡上的“环境变量”按钮来设置环境变量。某些版本的Windows将此控制面板提供在“系统”控制面板内的“高级系统设置”选项中。
然后,只需添加一个名为GOPATH
的变量,并设置正确的路径。为了确保不将标准包与你的包混合在一起,你应该选择一个与GOROOT
不同的位置。
英文:
For a quick way to install golang on windows, try the MSI installer. The installer will only add the C:\Go\bin
directory to your PATH
, you need to setup the GOPATH
manually in your environement settings.
From the golang site:
>Under Windows, you may set environment variables through the "Environment Variables" button on the "Advanced" tab of the "System" control panel. Some versions of Windows provide this control panel through the "Advanced System Settings" option inside the "System" control panel.
Then just add a variable name GOPATH
with the right location. You should choose a location different from GOROOT
to ensure you don't mix standard package with yours.
答案3
得分: 0
根据您的偏好和要求,可以尝试以下操作:
在Windows命令控制台中,尝试输入以下命令行,包括所示的引号,然后按下回车键:
setx PATH "c\go\bin;C:\go\src\gocode"
英文:
Based on your preferences and requirements, try this:
In windows command console, try enter the following line,
including the quote marks shown, and then hit ENTER key:
setx PATH "c\go\bin;C:\go\src\gocode"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论