golang-standards/project-layout

Public

Standard Go Project Layout

  • Stars56.7k+6 tuần này
  • Forks5.4k
  • Watchers591
  • Issues71
  • Ngày tạo09/09/2017
  • Cập nhật gần nhất29/04/2026
  • Ngôn ngữMakefile
  • Giấy phép—
README.md30.8 KBRaw

Standard Go Project Layout

Translations:

Overview

This is a basic layout for Go application projects. Note that it's basic in terms of content because it's focusing only on the general layout and not what you have inside. It's also basic because it's very high level and it doesn't go into great details in terms of how you can structure your project even further. For example, it doesn't try to cover the project structure you'd have with something like Clean Architecture.

This is NOT an official standard defined by the core Go dev team. This is a set of common historical and emerging project layout patterns in the Go ecosystem. Some of these patterns are more popular than others. It also has a number of small enhancements along with several supporting directories common to any large enough real world application. Note that the core Go team provides a great set of general guidelines about structuring Go projects and what it means for your project when it's imported and when it's installed. See the Organizing a Go module page in the official Go docs for more details. It includes the internal and cmd directory patterns (described below) and other useful information.

If you are trying to learn Go or if you are building a PoC or a simple project for yourself this project layout is an overkill. Start with something really simple instead (a single main.gofile andgo.mod is more than enough). As your project grows keep in mind that it'll be important to make sure your code is well structured otherwise you'll end up with a messy code with lots of hidden dependencies and global state. When you have more people working on the project you'll need even more structure. That's when it's important to introduce a common way to manage packages/libraries. When you have an open source project or when you know other projects import the code from your project repository that's when it's important to have private (aka

Nội dung README thuộc về golang-standards và cộng đồng đóng góp, giấy phép Không có giấy phép. Nguồn: github.com/golang-standards/project-layout