Go - Do I have one workspace for all projects, or one workspace per project?

Viewed 2798

When using Go how are projects organized? I'm a bit confused on the workspaces part. I've had a read of the following: https://golang.org/doc/code.html#Workspaces ... and this part has thrown me off a little:

A typical workspace contains many source repositories containing many packages and commands. Most Go programmers keep all their Go source code and dependencies in a single workspace.

Does this mean that for each project I create it is a seperate workspace? For example if two projects use the same package, I would have two copies of that package on my computer.

Or, does it mean you have a main workspace and your projects share those packages?

Bit confused.

3 Answers

I personally like to have a different GOPATH per project. If you are fine using a tool to automate the process you can use vg which will take care of managing different GOPATHs for your projects.

The neat bit is that it integrates with most shells and auto-detect projects as you cd them.

Related