Forked from golang-standards/project-layout
Standard Go Project Layout
This is a basic layout for Go application projects. It represents the most common directory structure with a number of small enhancements along with several supporting directories common to any real world application.
Clone the repository, keep what you need and delete everything else!
Go Project Layout - additional background information.
Main applications for this project.
The directory name for each application should match the name of the executable you want to have (e.g.,
Don't put a lot of code in the application directory unless you think that code can be imported and used in other projects. If this is the case then the code should live in the
It's common to have a small main function that imports and invokes the code from the
Private application and library code.
Put your actual application code in the
/internal/app directory (e.g.,
/internal/app/myapp) and the code shared by those apps in the
/internal/pkg directory (e.g.,
Library code that's safe to use by external applications (e.g.,
Other projects will import these libraries expecting them to work, so think twice before you put something here :-)
Application dependencies (managed manually or by your favorite dependency management tool).
Don't commit your application dependencies if you are building a library.
Service Application Directories
OpenAPI/Swagger specs, JSON schema files, protocol definition files.
Web Application Directories
Web application specific components: static web assets, server side templates and SPAs.
Common Application Directories
Configuration file templates or default configs.
consule-template template files here.
System init (systemd, upstart, sysv) and process manager/supervisor (runit, supervisord) configs.
Scripts to perform various build, install, analysis, etc operations.
These scripts keep the root level Makefile small and simple.
Packaging and Continous Integration.
Put your cloud (AMI), container (Docker), OS (deb, rpm, pkg) package configurations and scripts in the
Put your CI (travis, circle, drone) configurations and scripts in the
IaaS, PaaS, system and container orchestration deployment configurations and templates (docker-compose, kubernetes/helm, mesos, terraform, bosh).
Additional external test apps and test data.
Design and user documents (in addition to your godoc generated documentation).
Supporting tools for this project. Note that these tools can import code from the
Examples for your applications and/or public libraries.
External helper tools, forked code and other 3rd party utilities (e.g., Swagger UI).
Other assets to go along with your repository.
Go Report Card - It will scan your code with
github.com/golang-standards/project-layoutwith your project reference.
GoDoc - It will provide online version of your GoDoc generated documentation. Change the link to point to your project.
Release - It will show the latest release number for your project. Change the github link to point to your project.
A more opinionated project template with sample/reusable configs, scripts and code is a WIP.