My GOPATH is /Users/joe/go
. I am working on a project called myproj
, which is a package called myproj
.
If I want to be able to write import "myproj"
then the directory structure I need is:
$GOPATH/src/myproj/myproj.go
$GOPATH/src/myproj/myproj_test.go
...
However, I can't seem to make this fit with Git. If I look at an example package from Google I see the following format:
go.example/hello/hello.go
go.example/LICENSE
Where go.example
is the name of the repo.
So the actual package directories are found inside the repository. If I put the contents of this repository in a directory on my $GOPATH, e.g.
$GOPATH/src/go.example/hello/hello.go
$GOPATH/src/go.example/LICENSE
then I will have to type import "go.example/hello"
rather than import "hello"
.
Coming back to my project, I need to package this up in a Git repository then I need a container directory. So my current file structure is:
$GOPATH/src/myproj # The dir for the git repo
$GOPATH/src/myproj/.git
$GOPATH/src/myproj/LICENSE # Files in the base of the repo
$GOPATH/src/myproj/myproj/myproj.go # Package files in package dir
$GOPATH/src/myproj/myproj/myproj_test.go
I need the outer myproj
directory to bound the git repository and I need the inner one to be the package directory. The upshot is that I need to type import "myproj/myproj"
rather than import "myproj"
.
How do I fix this? Do I have to add multiple $GOPATHS, one for each project I'm developing?
Thanks in advance.