Is it bad practice to have a single directory to hold all git repositories (for all languages?)


(magvonim lahim) #1

My team at work has a single directory where we put all our git repositories for all languages.

For example the directory name is “git”, and under git there are all the git repositories: “some-python-project”, “some-powershell-project”, “golang_project”, “golang_project2” etc etc…

But I see that for Go it is problematic. I understood that for Go it’s best practice to have a single directory for many projects (such that each different project is in the src file under this directory.

Am I correct? Should I put my Golang projects outside this “git” directory?


(Norbert Melzer) #2

As with go 1.12 modules have been finally introduced and they become more and more state of the art, its fine to have your go projects where ever you like them.

And I really appreciate the change to not have to rely on the go worksapace anymore.

Though the very flat hirarchy you describe sounds confusing and unstructured to me.

Personally I prefer to have a folder per customer, and within that a folder per project.


(Holloway) #3

For all the Golang projects, if you’re using Go module and they are outside GOPATH, you will be fine. Project with module (go.mod file) is now the preferred method for development.

You only face case-by-case basis problem(s) if your GOPATH is pointing at the universal work directory (git). That confuses go since the “single directory” mechanism you mentioned is the old method of development. Yes, that pain you experienced is the very reason go module was released.

In case you want to know more about implementing module, https://github.com/golang/go/wiki/Modules would be a good start. It’s quite easy to implement.