faccio come scritto un tutorial Golang http://golang.org/doc/code.html#remotepacchetto code.google.com/p/go.example/hello: exec: "hg": file eseguibile non trovato in% PATH%. Come ottenere pacchetti golang a distanza?
mie impostazioni ENV:
C:\sbox\go\example>set go
GOPATH=C:\sbox\go\example
GOROOT=C:\Go
La cartella example/
ha solo src/
cartella:
C:\sbox\go\example\
|
--src\
Ora chiamo go get
come descritto e ottenere un errore:
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%
Dopo aver chiamato go get
, però, la mia cartella example/
diventa in questo modo:
C:\sbox\go\example\
|
--src\
|
code.google.com\
|
--p\
E questo è tutto. Niente di più installato.
Poi aggiungo un codice per la mia struttura di directory e diventa in questo modo:
C:\sbox\go\example\
|
--src\
|
---code.google.com\
| |
| --p\
|
---github.com\
|
--user\
|
--hello\
| |
| --hello.go
|
--newmath\
|
--sqrt.go
hello.go
è come questo:
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
è come questo:
// 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
}
Li copio/incollo. Tutto come scritto nel tutorial. Quindi faccio go install
ed eseguo il progetto. Tutto funziona benissimo:
C:\sbox\go\example\src\github.com\user\hello>go install
C:\sbox\go\example\bin>hello
Hello, world. Sqrt(2) = 1.414213562373095
Ora ho di nuovo corro go get
e ottengo lo stesso errore:
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, aggiungo bin/
directory al percorso e corro go get
di nuovo, ma ottengo lo stesso errore:
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%
Cosa devo fare per ottenere il risultato come descritto nel tutorial - i pacchetti remoti sono installati e posso usarli?