Workspace and dependencies

104 views
Skip to first unread message

raf.de...@gmail.com

unread,
Mar 27, 2017, 1:15:51 AM3/27/17
to golang-nuts
Hello everyone !

I'm new to golang and I have some questions about the workspace and the dependencies management.

I've read that GOPATH is the location of my workspace, where all of my go code belongs (personal project and dependencies of all of these projects).

If I want to push one of my project on github, will I push only my project source code or will I also push the dependencies ?
If I must push only my code, how another developer who wants to clone my repo can find the list of my dependencies and use the rights versions ?

Can I have two projects using two different version of the same project ? (It seems to be impossible if all of my project and dependencies are in the same folder).

Thanks for you answers !

Prabesh P

unread,
Mar 29, 2017, 8:33:06 AM3/29/17
to golang-nuts

mhh...@gmail.com

unread,
Mar 29, 2017, 10:06:42 AM3/29/17
to golang-nuts
To add to the previous answer,


> I've read that GOPATH is the location of my workspace, where all of my go code belongs (personal project and dependencies of all of these projects).

yes (so far)


> If I want to push one of my project on github, will I push only my project source code or will I also push the dependencies ?
you might do both, depending on the project.
If you decide to push your deps, they have to be located under vendor folder of the repo.
If you prefer not to push the deps, you might want to try dep https://github.com/golang/dep/ or glide (glide.sh)


> Can I have two projects using two different version of the same project ?
Yes, if the dependency exists within the vendor folder of each project.
On that subject, remember
- go resolves dependencies by their longest path (might be more complex in some cases, not sure),
- go resolves deps firstly in vendor, then into the WSpace (using above strat)

Welcome !
Reply all
Reply to author
Forward
0 new messages