Hi everyone, today I want to share a Go project structure that I have used and found useful. This project structure is suitable for medium and small projects, and even large projects. The way folders and files are organized in this project structure is similar to other programming languages such as NodeJS or Java. This helps everyone to have a more comprehensive and easier understanding when learning about Go. I hope it will be useful and here is my Go project structure.
âââ cmd/ # Contains executable applications
â âââ cli/ # Command-line application
â âââ cronjob/ # Scheduled jobs
â âââ server/ # Server application
â âââ main.go # Run the application
âââ config/ # Configuration for applications
â âââ config.yaml # Main configuration file
âââ docs/ # Project documentation
âââ global/ # Global variables
âââ internal/ # Internal packages
â âââ controller/ # Handle client requests
â âââ initialize/ # Initialize necessary components
â âââ middlewares/ # Server middlewares
â âââ models/ # Structs representing data
â âââ repo/ # Query data from the database
â âââ routers/ # Define routes for the server
â âââ service/ # Handle business logic
âââ migrations/ # Database migration scripts
âââ pkg/ # Reusable packages
â âââ logger/ # Logging for the application
â âââ response/ # Handle response to the client
â âââ setting/ # Application settings
â âââ utils/ # Utility functions
âââ scripts/ # Development support scripts
âââ tests/ # Test cases for the application
âââ third_party/ # Third-party libraries
âââ .gitignore # Git ignore file
âââ go.mod # Go dependencies management
âââ go.sum # Contains checksums of dependencies
âââ LICENSE # Project license
âââ README.md # Project description
This is the result of my project structure on Visual Studio Code
If you found this article useful and interesting, please share it with your friends and family. I hope you found it helpful. Thanks for reading đ
Let’s get connected! You can find me on:
Medium: Quang Hieu (Bee) — Medium
Linkedin: Quang Hieu (Bee) — Linkedin
Buy Me a Coffee: Quang Hieu (Bee) — buymeacoffee