问题
I do as written an the Golang tutorial http://golang.org/doc/code.html#remote
My env settings:
C:\sbox\go\example>set go
GOPATH=C:\sbox\go\example
GOROOT=C:\Go
The example/ folder has only src/ folder:
C:\sbox\go\example\
|
--src\
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%
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 is like this:
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 is like this:
// 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
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%
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?
回答1:
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.
来源:https://stackoverflow.com/questions/16900486/package-code-google-com-p-go-example-hello-exec-hg-executable-file-not-foun