How I Organize My Software Projects

From time to time I get the question on how I organize my software projects. I didn't come up with this structure by myself. I was (kind of) forced to use this structure, but now I'm very happy with it.

You may ask who forced me to use this structure. When I started programming in Go a couple of years ago, you were forced to use a path called GOPATH, which contained all source files for projects and binaries.

I won't go into the details of that, but the basic structure was the following:

.
├── bin
├── pkg
└── src
    ├── github.com
    │   └── some-awesome-organization
    │       └── some-awesome-repo
    └── gitlab.com
        ├── rak-n-rok
        │   └── krake
        └── danieltrautmann
            ├── docker-mdbook
            └── how-i

The structure below src basically reflects the URL to the repository which you would type into your browser. For example the URL to the repository of this site is https://gitlab.com/danieltrautmann/how-i, so the path on the local file system would be $GOPATH/src/gitlab.com/danieltrautmann/how-i.

This even offered me the possibility to automate the process for creating the directories and cloning of the Git repository using an Alfred workflow, which I do not use anymore, but the fact that the path on the file system reflects the URL makes automation a lot easier.

Since Go Modules were introduced, the GOPATH wasn't needed anymore, but I kept using this file structure. It is simple and you know exactly where the code is hosted.

If you do some freelance work like I do, than you will also have a separate directory for each organization you are working for, since this is part of the URL when they are services like GitHub, GitLab or Bitbucket. Even when they are hosting their own solution.

The only thing I changed when GOPATH wasn't needed anymore is that I dropped the bin, pkg and src directory. Now my structure looks like that:

.
├── bitbucket.org
│   └── awesome-team
│       └── awesome-project
└── gitlab.com
    └── danieltrautmann
        ├── docker-mdbook
        └── how-i

So all credits go to the team behind Go.