Hi Maurizio,
I tend to use go vendoring for this purpose.
I set GOPATH to $HOME, and this is my "global" environment. Each
project is checked out to its module path.
Instead of using 'go get' to get dependencies, I use git submodules via
vendetta. This checks out all of the dependencies for each project
under `vendor`, giving me a 'complete' environment for each project.
The vendored project is not included in my repository, just the SHA1 of
the version I'm depending on. The vendored projects' repositories are
kept under '.git/modules'. I have to run 'git submodule update --init'
when I change branches if the dependencies have changed.
This gives me reproducible builds, as well as "isolated" build
environments for each project I'm working on.
Installing a binary inside the project from the vendored directory is a
little awkward, something like:
ln -sf vendor src
[ -d bin ] || mkdir bin
export GOBIN=`pwd`/bin
cd src/github.com/mattes/migrate
go install
But generally for my own computer I don't care and can just 'go get
github.com/mattes/migrate' - the above is more for things like
continuous integration and deployment, where I want the tools installed
to be reproducible as well.
Hope that helps!
Sam
On 9/1/16 10:56 AM, Maurizio Vitale wrote:
> hello gophers,
>
> How people do use GOPATH?
>
> having a single workspace for all my projects doesn't really work for
> me. Some project might involve more than a go portion and really
> shoehorning them into a go tree doesn't sound right.
>
> I'm completely fine with switching GOPATH every time I switch project
> and there's a benefit in having the complete environment in the same
> tree. but how people handle internal include paths? the only thing I
> can think of is symlinking from down into the project path so that you
> can import as if you were from(say) github.com/user/project
> <http://github.com/user/project>.
>
> And even if switching, there're certain things I want to 'go get' and
> share across all projects. For instance godep and the such. I could
> switch GOPATH, go get and then just add the bin directory to PATH. Is
> this what people do? or do they have a complete set of tools per
> project (even this is defendible and I'm not completely against it)
>
> please enlighten me, thanks
> --
> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.