Skip to content

kyda-code/go-structure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Project Structure

The following is a folder pattern gathering from my years of experience and good practices like clean architecture.

Authors

Perks of Use this Structure

  • Ease to maintain
  • Ease to understand
  • Readable for all
  • Scalable for huge o small projects

Clean Architecture

My experience with Clean Architecture begins 3 years ago, applying it in different projects from retail, fintech, and e-commerce, in this time this tool became my base for resolving problems concerned with systems architecture.

In general Clean Architecture is a software design philosophy that separates the elements of a design into ring levels. The main rule of clean architecture is that code dependencies can only move from the outer levels inward.

Alt text

The author of this is the Uncle Bob Robert C. Martin if you need more information you can access his [blog](https://Clean Coder Blog)

Go Folders

  • /cmd => Contains all that we want to run, main application for the project

  • /internal => Contains all the code you don't want others importing in their application.

  • /pkg => Contains all the code that's ok to use bye external applications

    • /api => Define the configuration to run the API
    • /db => Contains the connection to database and migration logic
    • /utils => Contains utilities for the application like customExceptions, customErrors, customException, etc...
    • /services => Define each service that is used in the application
  • /vendors => Contains all applications dependencies created with go mod vendor

  • /handlers => Functions used to handle to process all request for the services

  • /models => Functions that used to represent the tables of the database

  • /schemas => Functions that used to represent the desired request structure

Common Directories

  • /web => Contains all application static components
  • /configs => Contains the all configurations related to the application as .env, or .yml
  • /scripts => Functions that used to trigger a function from another function
  • /build => Contains the file to create a container for the application (docket, deb, rpm, ...)
  • /tests => Collections of functions used to create different test, like a unit testing or integration testing

Notes

You don't need to implement this structure in your projects, this can be changed or updated depending on the needs of your project if you need to know more about the Golang, always access the official documentation here.

❤️ Happy Coding!! 😄

About

Structure Golang Project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published