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

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?

2 Likes

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.

4 Likes

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.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.