英文:
Go install not working on Window?
问题
我今天刚在我的Windows电脑上安装了Golang,并且设置了%GOPATH%
。然而,当我运行go install {...}
来安装各种二进制文件时,Windows找不到可执行文件。我的%GOROOT%
是C:\Go
,这是默认的.msi安装位置。
PS C:\Users\{user}\Development\go> ls
目录: C:\Users\{user}\Development\go
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/11/2015 9:02 PM bin
d---- 12/11/2015 11:08 AM pkg
d---- 12/11/2015 11:08 AM src
C:\Users\{user}\Development\go>echo %GOPATH%
C:\Users\{user}\Development\go
我是否错误地设置了环境变量?
英文:
I just installed Golang on my Windows box today, and I have my %GOPATH%
set. However, when I run go install {...}
for various binaries, Windows can't find the executables. My %GOROOT%
is C:\Go
, the default .msi install location.
PS C:\Users\{user}\Development\go> ls
Directory: C:\Users\{user}\Development\go
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/11/2015 9:02 PM bin
d---- 12/11/2015 11:08 AM pkg
d---- 12/11/2015 11:08 AM src
C:\Users\{user}\Development\go>echo %GOPATH%
C:\Users\{user}\Development\go
Do I have the environmental variables set incorrectly?
答案1
得分: 4
> Windows无法找到可执行文件
如果你指的是通过go install
从你的go程序构建的可执行文件,并且由Go在%GOPATH%\bin
中提供,你只需要将%GOPATH%\bin
添加到你的PATH
环境变量中(除了%GOROOT%\bin
)。
set PATH=%PATH%;%GOPATH%\bin
cd %GOPATH%\src\path\to\a\go\project
go install
然后你就可以调用你的可执行文件了,Windows会在%GOPATH%\bin
(即C:\Users\{user}\Development\go\bin
文件夹)中找到它。
英文:
> Windows can't find the executables
If you mean the executable built from your go programs (by go install
) and delivered by Go in %GOPATH%\bin
, all you need is to add to your PATH
environment variable %GOPATH%\bin
(in addition of %GOROOT%\bin
)
set PATH=%PATH%;%GOPATH%\bin
cd %GOPATH%\src\path\to\a\go\project
go install
Then you can call your executable, and Windows will find it in %GOPATH%\bin
(the C:\Users\{user}\Development\go\bin
folder)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论