2

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)

Shadoninja
  • 1,276
  • 1
  • 12
  • 22
  • Bummer. Then maybe check out `/myname/appname` into `$GOPATH/src/orgname/appname` (or whatever path corresponds to the master URL), and do your work there. If you need to work with multiple forks, switch GOPATHs or swap them out via mv, etc. – twotwotwo Feb 14 '15 at 00:34
  • The flow sucks a little then (at a minimum, you can't just use "go get" anymore) but if your team mandates you work on forks I don't see anything better. Maybe someone'll answer with something better, though. – twotwotwo Feb 14 '15 at 00:35
  • See https://splice.com/blog/contributing-open-source-git-repositories-go/ – Charlie Tumahai Feb 14 '15 at 00:47
  • Yeah checking out my fork into the file path relating to the main fork fixed it. Good idea. – Shadoninja Feb 19 '15 at 20:48

1 Answers1

2

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.

  • Yes! This is it. Even though my forked version has a different path, I can ignore that by simply building the file structure that complies with the import paths. Good answer (your first suggestion worked smoothly) – Shadoninja Feb 19 '15 at 19:11