6g: No such file or directory - Building Go packages with `gomake` on Snow Leopard
I have two .go
files, numbers.go
and numbers_test.go
and I want to build and execute the tests as per the creating a new package tutorial (scroll down for details on the files.) All files are in the same directory.
When I navigate to that directory in Terminal and type gomake
I get this:
6g -o _go_.6 numbers.go
make: 6g: No such file or directory
make: *** [_go_.6] Error 1
This error is saying that it cannot find numbers.go
. If I manually execute this line (without moving directory):
6g -o _go_.6 numbers.go
it successfully creates the _go_.6
file. So why can't gomake
find the file?
Here are the files I am using:
numbers.go
l开发者_JAVA百科ooks like this:
package numbers
func Double(i int) int {
return i * 2
}
numbers_test.go
looks like this:
package numbers
import (
"testing"
)
type doubleTest struct {
in, out int
}
var doubleTests = []doubleTest{
doubleTest{1, 2},
doubleTest{2, 4},
doubleTest{-5, -10},
}
func TestDouble(t *testing.T) {
for _, dt := range doubleTests {
v := Double(dt.in)
if v != dt.out {
t.Errorf("Double(%d) = %d, want %d.", dt.in, v, dt.out)
}
}
}
and finally, my Makefile
looks like this:
include $(GOROOT)/src/Make.inc
TARG=numbers
GOFILES=\
numbers.go
include $(GOROOT)/src/Make.pkg
The error doesn't say that it can't find numbers.go
- it's saying that it can't find 6g
. In your Makefile, try putting the path to 6g
in your PATH, as well as any other Go-specific environment variables.
精彩评论