Organizing your Go (Golang) project's folder structure can help improve code readability, maintainability, and scalability. While there is no one-size-fits-all structure, here's a common folder structure for a Go project:
├── cmd/
│ ├── your-app-name/
│ │ ├── main.go # Application entry point
│ │ └── ... # Other application-specific files
│ └── another-app/
│ ├── main.go # Another application entry point
│ └── ...
├── internal/ # Private application and package code
│ ├── config/
│ │ ├── config.go # Configuration logic
│ │ └── ...
│ ├── database/
│ │ ├── database.go # Database setup and access
│ │ └── ...
│ └── ...
├── pkg/ # Public, reusable packages
│ ├── mypackage/
│ │ ├── mypackage.go # Public package code
│ │ └── ...
│ └── ...
├── api/ # API-related code (e.g., REST or gRPC)
│ ├── handler/
│ │ ├── handler.go # HTTP request handlers
│ │ └── ...
│ ├── middleware/
│ │ ├── middleware.go # Middleware for HTTP requests
│ │ └── ...
│ └── ...
├── web/ # Front-end web application assets
│ ├── static/
│ │ ├── css/
│ │ ├── js/
│ │ └── ...
│ └── templates/
│ ├── index.html
│ └── ...
├── scripts/ # Build, deployment, and maintenance scripts
│ ├── build.sh
│ ├── deploy.sh
│ └── ...
├── configs/ # Configuration files for different environments
│ ├── development.yaml
│ ├── production.yaml
│ └── ...
├── tests/ # Unit and integration tests
│ ├── unit/
│ │ ├── ...
│ └── integration/
│ ├── ...
├── docs/ # Project documentation
├── .gitignore # Gitignore file
├── go.mod # Go module file
├── go.sum # Go module dependencies file
└── README.md # Project README
git clone https://github.com/Viky-Developer/Go-Basic.git
$ go mod tidy