问题
I am very new at Go, and need a bit of help with a way to make import pathing more distributable between my team.
Currently at the top of one of my Go files, I have an import, say "github.teamName.com/teamMemberA/HeartThrob/c"
I forked his project to my own name and downloaded it and got some pretty obvious import errors.
MY path to the file it is trying to import is the following: "github.teamName.com/myName/HeartThrob/c"
This pathing change is because I am pulling the project from my own forked repo.
What is a way I can go about fixing this? Is relative pathing possible? I can't put all the Go files into the same directory due to the size of the project and some obvious places for separation.
Disclaimer: New to Go AND Git (My forked approach is team-mandated though)
回答1:
Assuming that GOPATH contains a single element, do this:
$ mkdir -p $GOPATH/github.teamName.com/teamMemberA
$ cd $GOPATH/github.teamName.com/teamMemberA
$ git clone github.teamName.com/myName/HeartThrob
$ cd HeartThrob/c
$ go install
An alternative approach is:
$ go get github.teamName.com/teamMemberA/HeartThrob/c
$ cd $GOPATH/github.teamName.com/teamMemberA/HeartThrob
$ git remote add fork git@github.myName/HeartThrob.git
Hack a way and push to fork.
来源:https://stackoverflow.com/questions/28510180/is-there-a-way-to-have-reusable-pathing-for-imports-on-go-projects