wiscaksono / go-plate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My Go Project with Fiber and GORM

This is a template for organizing a Go project using the Fiber web framework and GORM ORM.

Project Structure

go/
|-- cmd/
|   |-- myapp/
|       |-- main.go
|
|-- internal/
|   |-- app/
|       |-- handler/
|       |   |-- handler1.go
|       |   |-- handler2.go
|       |
|       |-- middleware/
|       |   |-- middleware1.go
|       |   |-- middleware2.go
|       |
|       |-- model/
|       |   |-- model1.go
|       |   |-- model2.go
|       |
|       |-- repository/
|       |   |-- repository1.go
|       |   |-- repository2.go
|       |
|       |-- router/
|           |-- router.go
|
|-- config/
|   |-- config.go
|
|-- go.mod
|-- go.sum
|-- README.md

Overview

  • cmd: Contains the main application. main.go initializes and runs the application.
  • internal/app: Main application logic.
    • handler: Handles HTTP requests and responses.
    • middleware: Custom middleware functions.
    • model: Data models.
    • repository: Database access logic using GORM.
    • router: Initializes and configures the router.
  • scripts: Project-related scripts (e.g., setup and seeding scripts).
  • config: Configuration settings for the application.

Usage

  1. Clone the repository:
git clone https://github.com/wiscaksono/go-plate.git
  1. Install dependencies:
cd myproject
go mod download
  1. Run the application
go run cmd/myapp/main.go

Database Migrations

Apply database migrations using GORM:

go run cmd/myapp/main.go migrate

Contributing

Feel free to contribute by opening issues or pull requests.

About


Languages

Language:Go 98.5%Language:Makefile 0.9%Language:Dockerfile 0.7%