程序包code.google.com/p/go.example/hello:exec:"hg":在%PATH%中找不到可执行文件.如何获得远程golang软件包? [英] package code.google.com/p/go.example/hello: exec: "hg": executable file not found in %PATH%. How to get remote golang packages?
问题描述
我是按照Golang教程 http://golang.org/doc/code编写的.html#remote
I do as written an the Golang tutorial http://golang.org/doc/code.html#remote
我的环境设置:
C:\sbox\go\example>set go
GOPATH=C:\sbox\go\example
GOROOT=C:\Go
example/
文件夹仅具有 src/
文件夹:
The example/
folder has only src/
folder:
C:\sbox\go\example\
|
--src\
现在,我按照所述致电 go get
并收到错误消息:
Now I call go get
as described and get an error:
C:\sbox\go\example>go get code.google.com/p/go.example/hello
# cd .; hg clone -U https://code.google.com/p/go.example C:\sbox\go\example\src\code.google.com\p\go.example
package code.google.com/p/go.example/hello: exec: "hg": executable file not found in %PATH%
在调用 go 之后,我的
example/
文件夹变成了这样:
After calling go get
, though, my example/
folder becomes like this:
C:\sbox\go\example\
|
--src\
|
code.google.com\
|
--p\
仅此而已.无需再安装了.
And that's all. Nothing more installed.
然后,我将代码添加到目录结构中,如下所示:
Then I add a code to my directory structure and it becomes like this:
C:\sbox\go\example\
|
--src\
|
---code.google.com\
| |
| --p\
|
---github.com\
|
--user\
|
--hello\
| |
| --hello.go
|
--newmath\
|
--sqrt.go
hello.go
是这样的:
package main
import (
"fmt"
"github.com/user/newmath"
//"code.google.com/p/go.example/newmath"
)
func main() {
fmt.Printf("Hello, world. Sqrt(2) = %v\n", newmath.Sqrt(2))
}
sqrt.go
像这样:
// Package newmath is a trivial example package.
package newmath
// Sqrt returns an approximation to the square root of x.
func Sqrt(x float64) float64 {
z := 0.0
for i := 0; i < 1000; i++ {
z -= (z*z - x) / (2 * x)
}
return z
}
我只是应付/粘贴它们.全部如本教程中所写.然后,我开始安装
并运行该项目.一切正常:
I just cope/paste them. All as written in the tutorial. Then I do go install
and run the project. All works fine:
C:\sbox\go\example\src\github.com\user\hello>go install
C:\sbox\go\example\bin>hello
Hello, world. Sqrt(2) = 1.414213562373095
现在,我再次运行 go get
并得到相同的错误:
Now I again run go get
and get the same error:
C:\sbox\go\example>go get code.google.com/p/go.example/hello
# cd .; hg clone -U https://code.google.com/p/go.example C:\sbox\go\example\src\code.google.com\p\go.example
package code.google.com/p/go.example/hello: exec: "hg": executable file not found in %PATH%
好吧,我将 bin/
目录添加到PATH并再次运行 go get
,但得到相同的错误:
Ok, I add bin/
directory to the PATH and run go get
again but get the same error:
C:\sbox\go\example>set PATH=%PATH%;C:\sbox\go\example\bin
C:\sbox\go\example>go get code.google.com/p/go.example/hello
# cd .; hg clone -U https://code.google.com/p/go.example C:\sbox\go\example\src\code.google.com\p\go.example
package code.google.com/p/go.example/hello: exec: "hg": executable file not found in %PATH%
我需要如何获得本教程中所述的结果-已安装远程软件包并且可以使用它们?
What do I need to do get the result as described in the tutorial - remote packages are installed and I can use them?
推荐答案
您要安装的软件包在Mercurial( hg
)源代码管理系统下.您需要安装 Mercurial 才能克隆该软件包.
The package you are trying to install is under the Mercurial (hg
) source control system. You need to install Mercurial to be able to clone the package.
这篇关于程序包code.google.com/p/go.example/hello:exec:"hg":在%PATH%中找不到可执行文件.如何获得远程golang软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!