Skip to content
/ go-project-layout Public template

๐Ÿ”ฎ A canonical Go project structure and layout for generating scaffolding projects.

License

Notifications You must be signed in to change notification settings

kubecub/go-project-layout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โญ๏ธ Template for a typical module written on Go โญ๏ธ

๐Ÿงฉ Awesome features

At Github, we want to start new projects faster using best practices with a predefined structure and focusing on core ideas implementation rather than wasting time on environment configuration and copying boilerplate code.

I defined a spec template that I could use to quickly start building a full-fledged project.

In each directory, there is a README.md and an OWNERS, which explains what the directory does and who owns it.

Labels denger: Read about the go-project-layout tag design. We have provided in the github-label-syncer warehouse label synchronizer.

๐Ÿ›ซ Quick start

Note: You can get started quickly with go-project-layout.

  1. Generate a new repository from the template.
  2. Clone the repository locally.
  3. Update files, read the README files in each directory.
  4. Write your code and tests.
Work with Makefile
โฏ make help    # show help
โฏ make build   # build binary
Git hook(push & commit)
โฏ make # To trigger the hook script, move to.git
โฏ tree .git/hooks
.git/hooks
โ”œโ”€โ”€ applypatch-msg.sample
โ”œโ”€โ”€ commit-msg
โ”œโ”€โ”€ commit-msg.sample
โ”œโ”€โ”€ fsmonitor-watchman.sample
โ”œโ”€โ”€ post-update.sample
โ”œโ”€โ”€ pre-applypatch.sample
โ”œโ”€โ”€ pre-commit
โ”œโ”€โ”€ pre-commit.sample
โ”œโ”€โ”€ pre-merge-commit.sample
โ”œโ”€โ”€ pre-push
โ”œโ”€โ”€ pre-push.sample
โ”œโ”€โ”€ pre-rebase.sample
โ”œโ”€โ”€ pre-receive.sample
โ”œโ”€โ”€ prepare-commit-msg.sample
โ”œโ”€โ”€ push-to-checkout.sample
โ””โ”€โ”€ update.sample
โฏ cp ../sealer/_output/bin/sealer/linux_amd64/sealer ./ # add big binary file
โฏ git add .
โฏ git commit -a -s -m "nono"    # Excess commit blocking
kubecub : Running local kubecub pre-commit hook.
kubecub : File sealer is 71 MB, which is larger than our configured limit of 2 MB
kubecub : If you really need to commit this file, you can override the size limit by setting the GIT_FILE_SIZE_LIMIT environment variable, e.g. GIT_FILE_SIZE_LIMIT=42000000 for 42MB. Or, commit with the --no-verify switch to skip the check entirely.
kubecub : Commit aborted
โฏ rm -rf .git # remote big binary 
โฏ git commit -a -s -m "nono"    # Bad commit blocking
kubecub : Running local kubecub pre-commit hook.
kubecub : Running the kubecub commit-msg hook.
fakehsh: subject does not match regex [^(build|chore|ci|docs|feat|feature|fix|perf|refactor|revert|style|test)(.*)?:\s?.*]
fakehsh: subject length less than min [10]
kubecub : Please fix your commit message to match kubecub coding standards
kubecub : https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md
โฏ git commit -a -s -m "docs(main): README-en Chinese documentation"
kubecub : Running local kubecub pre-commit hook.
kubecub : Running the kubecub commit-msg hook.
[main b3b339f] docs(main): README-en Chinese documentation
 1 file changed, 29 insertions(+)
โฏ git push origin main
Work with actions

Actions provide handling of PR and issue. We used the bot ๐Ÿš€@kubbot, It can detect issues in Chinese and translate them to English, and you can interact with it using the command /comment.

Comment in an issue:

โฏ /intive
Work with Tools
โฏ make tools
Work with Docker
โฏ make deploy

๐Ÿ•‹ architecture diagram

// architecture diagram

MVC Architecture Design:

// MVC Architecture Design

๐Ÿค– File Directory Description

Catalog standardization design structure:

.go-project-layout
โ”œโ”€โ”€ CONTRIBUTING.md          # Contribution guidelines
โ”œโ”€โ”€ LICENSE                  # License information
โ”œโ”€โ”€ Makefile                 # Makefile for building and running the project
โ”œโ”€โ”€ README.md                # Project overview in English
โ”œโ”€โ”€ README_zh-CN.md          # Project overview in Chinese
โ”œโ”€โ”€ api                      # API-related files
โ”‚   โ”œโ”€โ”€ OWNERS               # API owners
โ”‚   โ””โ”€โ”€ README.md            # API documentation
โ”œโ”€โ”€ assets                   # Static assets, such as images and stylesheets
โ”‚   โ””โ”€โ”€ README.md            # Assets documentation
โ”œโ”€โ”€ build                    # Build-related files
โ”‚   โ”œโ”€โ”€ OWNERS               # Build owners
โ”‚   โ””โ”€โ”€ README.md            # Build documentation
โ”œโ”€โ”€ cmd                      # Command-line tools and entry points
โ”‚   โ”œโ”€โ”€ OWNERS               # Command owners
โ”‚   โ””โ”€โ”€ README.md            # Command documentation
โ”œโ”€โ”€ configs                  # Configuration files
โ”‚   โ”œโ”€โ”€ OWNERS               # Configuration owners
โ”‚   โ”œโ”€โ”€ README.md            # Configuration documentation
โ”‚   โ””โ”€โ”€ config.yaml          # Main configuration file
โ”œโ”€โ”€ deploy                   # Deployment-related files
โ”‚   โ”œโ”€โ”€ OWNERS               # Deployment owners
โ”‚   โ””โ”€โ”€ README.md            # Deployment documentation
โ”œโ”€โ”€ docs                     # Project documentation
โ”‚   โ”œโ”€โ”€ OWNERS               # Documentation owners
โ”‚   โ””โ”€โ”€ README.md            # Documentation index
โ”œโ”€โ”€ examples                 # Example code and usage
โ”‚   โ”œโ”€โ”€ OWNERS               # Example owners
โ”‚   โ””โ”€โ”€ README.md            # Example documentation
โ”œโ”€โ”€ init                     # Initialization files
โ”‚   โ”œโ”€โ”€ OWNERS               # Initialization owners
โ”‚   โ””โ”€โ”€ README.md            # Initialization documentation
โ”œโ”€โ”€ internal                 # Internal application code
โ”‚   โ”œโ”€โ”€ OWNERS               # Internal code owners
โ”‚   โ”œโ”€โ”€ README.md            # Internal code documentation
โ”‚   โ”œโ”€โ”€ app                  # Application logic
โ”‚   โ”œโ”€โ”€ pkg                  # Internal packages
โ”‚   โ””โ”€โ”€ utils                # Utility functions and helpers
โ”œโ”€โ”€ pkg                      # Public packages and libraries
โ”‚   โ”œโ”€โ”€ OWNERS               # Package owners
โ”‚   โ”œโ”€โ”€ README.md            # Package documentation
โ”‚   โ”œโ”€โ”€ common               # Common utilities and helpers
โ”‚   โ”œโ”€โ”€ log                  # Log utilities
โ”‚   โ”œโ”€โ”€ tools                # Tooling and scripts
โ”‚   โ”œโ”€โ”€ utils                # General utility functions
โ”‚   โ””โ”€โ”€ version              # Version information
โ”œโ”€โ”€ scripts                  # Scripts for development and automation
โ”‚   โ”œโ”€โ”€ LICENSE_TEMPLATES    # License templates
โ”‚   โ”œโ”€โ”€ OWNERS               # Script owners
โ”‚   โ”œโ”€โ”€ README.md            # Script documentation
โ”‚   โ”œโ”€โ”€ githooks             # Git hooks for development
โ”‚   โ””โ”€โ”€ make-rules           # Makefile rules and scripts
โ”œโ”€โ”€ test                     # Test files and test-related utilities
โ”‚   โ”œโ”€โ”€ OWNERS               # Test owners
โ”‚   โ””โ”€โ”€ README.md            # Test documentation
โ”œโ”€โ”€ third_party              # Third-party dependencies and libraries
โ”‚   โ””โ”€โ”€ README.md            # Third-party documentation
โ”œโ”€โ”€ tools                    # Tooling and utilities for development
โ”‚   โ””โ”€โ”€ README.md            # Tool documentation
โ””โ”€โ”€ web                      # Web-related files, such as HTML and CSS
    โ”œโ”€โ”€ OWNERS               # Web owners
    โ””โ”€โ”€ README.md            # Web documentation

๐Ÿ—“๏ธ community meeting

We welcome everyone to join us and contribute to go-project-layout, whether you are new to open source or professional. We are committed to promoting an open source culture, so we offer community members neighborhood prizes and reward money in recognition of their contributions. We believe that by working together, we can build a strong community and make valuable open source tools and resources available to more people. So if you are interested in go-project-layout, please join our community and start contributing your ideas and skills!

We take notes of each biweekly meeting in GitHub discussions, and our minutes are written in Google Docs.

go-project-layout maintains a public roadmap. It gives a a high-level view of the main priorities for the project, the maturity of different features and projects, and how to influence the project direction.

๐Ÿคผโ€ Contributing & Development

kubecub Our goal is to build a top-level open source community. We have a set of standards, in the Community repository.

If you'd like to contribute to this go-project-layout repository, please read our contributor documentation.

Before you start, please make sure your changes are in demand. The best for that is to create a new discussion OR Slack Communication, or if you find an issue, report it first.

๐Ÿšจ License

Kubecub is licensed under the MIT License. See LICENSE for the full license text.

FOSSA Status

๐Ÿ”ฎ Thanks to our contributors!

About

๐Ÿ”ฎ A canonical Go project structure and layout for generating scaffolding projects.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published