程序包code.google.com/p/go.example/hello:exec:“ hg”:在%PATH%中找不到可执行文件。如何获得远程golang软件包?

绿色 :

我是按照Golang教程http://golang.org/doc/code.html#remote编写的

我的环境设置:

C:\sbox\go\example>set go
    GOPATH=C:\sbox\go\example
    GOROOT=C:\Go

example/文件夹只有一个src/文件夹:

C:\sbox\go\example\
             |
             --src\

现在,我按说明致电go get并收到错误消息:

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 get但是,在调用之后,我的example/文件夹将变为:

C:\sbox\go\example\
             |
             --src\
                |
                code.google.com\
                       |
                       --p\

就这样。没有更多的安装。

然后,将代码添加到目录结构中,结果如下所示:

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
}

我只是应付/粘贴它们。全部如本教程中所写。然后,我go install运行该项目。一切正常:

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并得到相同的错误:

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再次运行,但收到相同的错误:

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%

如本教程所述,我需要做什么才能得到结果-已安装远程软件包并且可以使用它们?

我:

您尝试安装的软件包位于Mercurial(hg)源代码管理系统下。您需要安装Mercurial才能克隆该软件包。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章