Reputation: 427
I've been toying around Go for a couple of weeks now, so far so good. Now I am writing a program splitted across different files like this:
.
|-- geometry
| |-- cone
| `-- cone.go
|-- main.go
|-- Makefile
the problem is i can't import cone.go in the main.go, the compiler doesn't find it. Anybody?
Upvotes: 3
Views: 624
Reputation: 9635
If you don't mind a bit of reading, this link has a lengthy discussion on the problem you're asking about.
Here's a short answer.
Import looks for package in $GOROOT/pkg (IIRC), it does not look in local directories. What you can do is make a seperate makefile for "geometry" using the go package makefile includes (see here) and then have your main makefile make the package and pass the -I
to include the new package in ./geometry
Upvotes: 2
Reputation: 11706
From the gc docs:
Flags:
-o file
output file, default 6.out for 6g, etc.
-e normally the compiler quits after 10 errors; -e prints all errors
-I dir1 -I dir2
add dir1 and dir2 to the list of paths to check for imported packages
-N disable optimization
-S write assembly language text to standard output
-V print the compiler version
Try adding -I geometry
to your compiler options.
Upvotes: 0