Golang Simple Boilerplate with Gofiber & Gorm

Golang Simple Boilerplate with Gofiber & Gorm

Boilerplate Structure

  • config/
  • controller/
  • entity/
  • exception/
  • helper/
  • middleware/
  • model/
  • repository/
  • seed/
  • service/
  • test/
  • validation/
  • .env.example
  • .env
  • .env.test
  • .gitignore
  • main.go
  • README.md

Definisi

  • config/ - Konfigurasi API, contohnya konfigurasi koneksi Elasticsearch, Mysql, MongoDB, Redis, Kafka, etc.
  • controller/ - Tempat Controller semua route Gofiber, contohnya mengatur endpoint, request ke Service, etc.
  • entity/ - Entity yang biasanya berisi field-field yang akan digunakan/dipanggil dari database.
  • contohnya insert/get data dari redis, ubah type string ke type int, etc.
  • middleware/ - Mirip seperti helper, middleware biasa digunakan pada Controller untuk diproses sebelum controller berjalan/selesai.
  • model/ - Mirip seperti entity, model biasanya digunakan untuk memberikan response atau sebagai value return.
  • repository/ - Tempat proses transaksi dari/ke database.
  • seed/ -
  • service/ - Sebagai jembatan antara Controller dan Service. Biasa digunakan untuk handle/validasi data sebelum dilanjut ke Repository.
  • test/ - Tempat file-file Unit Test Golang.
  • validation/ - Mirip seperti helper, validation biasanya digunakan/dipanggil di Service.
  • .env.example - Contoh/format environment untuk disalin
  • .env - Environment utama/production
  • .env.test - Environment untuk testing
  • .gitignore - Ignore file/folder saat push ke git
  • main.go - File utama/main Golang, tempat panggil Repository, Service, Controller.
  • README.md - File README

Trivial & Tips

  • Lebih baik gunakan Service untuk logic sebelum masuk ke repository.
  • Lebih baik gunakan Struct dari Model untuk Response, supaya lebih mudah penggunaannya.
  • Selalu gunakan .env.test untuk Unit Testing.
Similar Resources

Simple Bank is a simple REST API that allows users to perform transferences with each other.

Simple Bank is a simple REST API that allows users to perform transferences with each other. 🔧 Technologies Golang Docker PostgreSQ

Feb 15, 2022

Go Getting Started from PluralSight. Simple webapp in golang

Go_WEB_APP Go Getting Started from PluralSight. Simple webapp in golang This is simple Webapp in GO, which has users api to interact with backend This

Oct 18, 2021

Golang beego framework based personal simple blog system

Golang beego framework based personal simple blog system

goblog 基于Golang的个人简易博客系统 [TOC] goblog介绍 goblog基于go语言开发的一个简约版个人博客系统,基于Golang语言编写,后端基于了Beego的web框架,目前具备博文系统最基础的功能模块.基本上是一个拿来即用的个人博文平台,只需要部署一个mysql数据存储服务

Nov 9, 2021

A simple web application written in Golang which listens on port 8080

GoWebApp It's a simple web application written in Golang which listens on port 8080 Building It can be build using the command go build -o metricsweba

Oct 21, 2021

A simple RESTful server with golang

A simple RESTful server Setup local development environment cp develop.env .env docker-compose up -d docker-compose exec mysql mysql -u root --passwor

Oct 28, 2021

A simple demo written in Golang to shorten URL and redirect

url-shortener A simple demo written in Golang to shorten URL and redirect . ├── go.mod ├── go.sum ├── handler │ └── handlers.go ├── main.go ├── shor

Jun 5, 2022

Simple control panel for Golang based on Gin framework and MongoDB

Simple control panel for Golang based on Gin framework and MongoDB

Summer panel Simple control panel for Golang based on Gin framework and MongoDB How To Install go install github.com/night-codes/summer/summerGen@late

Dec 16, 2022

Simple Todolist using Golang IO and Mysql

Simple Todolist using Golang IO and Mysql HOW TO USE create 2 database with name : todolist for product todolist_test for test create table in both da

Nov 22, 2021

A simple supermarket API implemented in Golang

supermarket-api The supermarket-api is a Golang application that responds to HTTP requests for updating produce information in a backend database. The

Nov 24, 2021
Gin-boilerplate - Gin boilerplate preconfigured with basic rest api features

Gin Boilerplate Build apis with gin faster with this template Features Validatio

Jun 24, 2022
Dating-server - Go (Golang) API REST Template/Boilerplate with Gin Framework

go-rest-template Go (Golang) API REST Template/Boilerplate with Gin Framework 1.

Apr 3, 2022
Golang : Use gorm with mysql in gin

Golang : Use gorm with mysql in gin This repository guides to how ORM can be implemented in Golang. After cloning the code, follow below steps to let

Dec 9, 2021
Implementation of clean architecture in golang with gin-gonic & gorm

Boilerplate API Boilerplate API template includes all the common packages and setup used for API development in this Company. Development Copy .env.ex

Feb 15, 2022
Go Server/API boilerplate using best practices DDD CQRS ES gRPC
Go Server/API boilerplate using best practices DDD CQRS ES gRPC

Go Server/API boilerplate using best practices DDD CQRS ES gRPC

Jan 6, 2023
前端使用Vue3、CompositionAPI、typescript、vite、element plus,后端使用Go + Gin + Gorm,实现的后端管理系统,支持菜单、页面按钮及后端API的权限管控。
前端使用Vue3、CompositionAPI、typescript、vite、element plus,后端使用Go + Gin + Gorm,实现的后端管理系统,支持菜单、页面按钮及后端API的权限管控。

本系统使用最新的 Vue3 及相关技术栈,实现了菜单及页面按钮的权限管控,基于 Casbin 实现了后端 API 接口的管控,不进行过度的封装,代码简洁易懂,方便二次开发及当成后端管理平台脚手架使用,数据库暂时仅支持 postgres 。 演示站点:http://fdevops.com:8088 文

Apr 1, 2022
Menggunakan gol ver 1.13.15 dan framework gin dan gorm

Menggunakan gol ver 1.13.15 dan framework gin dan gorm

Jul 11, 2022
Go-gin-ddd-cqrs - Clean api rest with Go, Gin and GORM
Go-gin-ddd-cqrs - Clean api rest with Go, Gin and GORM

GOLANG API REST Clean api rest with Go, Gin and GORM. Clean Architecture with DD

Oct 21, 2022
A ToDoList Demo based on Vue+Gin+Gorm+mysql
A ToDoList Demo based on Vue+Gin+Gorm+mysql

bubble清单 一个基于gin+gorm开发的练手小项目,通过该项目可初识go web开发该有的姿势。 前端页面基于vue和ElementUI开发,对前端不熟悉的童鞋可直接下载templates和static文件夹下的内容使用。 使用指南 下载 [email protected]:mao888/GoWe

Mar 16, 2022
A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.
A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.

A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.

Oct 10, 2021