Skip to content

GoProjects-and-samples/simple_user_login

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myapp/ ├── cmd/ # Entry points (main packages) │ └── myapp/ # Main app entry (main.go) ├── internal/ # Private app code │ ├── config/ # Configuration handling │ ├── handler/ # HTTP handlers (controllers) │ ├── service/ # Business logic │ ├── repository/ # Data access logic │ └── model/ # Domain models ├── pkg/ # Reusable packages (public) │ └── utils/ # Utilities used across the app ├── web/ # Frontend assets (HTML, JS, CSS) │ ├── static/ # Static files │ └── templates/ # HTML templates ├── migrations/ # DB schema and migration files ├── go.mod # Go module definition ├── go.sum # Go module checksums └── README.md When building a Go (Golang) web application, it's important to organize your folder structure in a way that supports scalability, maintainability, and testability. There’s no one-size-fits-all, but here is a commonly used idiomatic folder structure for a Go web app:


🧱 Recommended Folder Structure

myapp/
├── cmd/                # Entry points (main packages)
│   └── myapp/          # Main app entry (main.go)
├── internal/           # Private app code
│   ├── config/         # Configuration handling
│   ├── handler/        # HTTP handlers (controllers)
│   ├── service/        # Business logic
│   ├── repository/     # Data access logic
│   └── model/          # Domain models
├── pkg/                # Reusable packages (public)
│   └── utils/          # Utilities used across the app
├── web/                # Frontend assets (HTML, JS, CSS)
│   ├── static/         # Static files
│   └── templates/      # HTML templates
├── migrations/         # DB schema and migration files
├── go.mod              # Go module definition
├── go.sum              # Go module checksums
└── README.md

📝 Notes on Key Folders

  • cmd/myapp/main.go Entry point for your application. Keeps the root directory clean when you have multiple binaries.

  • internal/ Code here is private to the module. This is where your core logic resides:

    • handler/ handles HTTP routing and responses.
    • service/ contains business logic.
    • repository/ manages database interactions.
    • model/ defines your data structures.
  • pkg/ Code intended to be imported by other apps (e.g., utilities or shared libraries).

  • web/ Stores frontend files served by the app.

  • migrations/ Keeps SQL files or Go-based migration scripts (for tools like golang-migrate or goose).

About

First GO app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors