Getting Started
GIMBAP is a framework aimed to quickly build and manage web applications in Go. It borrows some concepts from Spring Boot and NestJS and adapts them into a pattern that is more suitable for Go.
The following guide will help you quickly get started with the concepts of GIMBAP and make it possible to build a simple module managed web application.
Installation
You can either implicitly install by importing the package like this
import "github.com/jhseong7/gimbap"
or explicitly install the package yourself
go get -u github.com/jhseong7/gimbap
Initial Folder setup
Since GIMBAP is a framework that is designed to manage code in a modularized way, it is recommended to use a folder structure that is similar to frameworks of other languages.
The options recommended are as follows:
- sub-folder by features
- e.g. user, post, comment, etc.
- all the code related to the feature should be in the same folder
- sub-folder by types (models, services, controllers, etc.)
- e.g. models, services, controllers, etc.
- all the code related to the type should be in the same folder
However any folder structure you prefer is fine as long as you can manage the code well. 😃
Sample Folder Structures
By Features
main.go in the root folder
- module.go
- user-service.go
- user-controller.go
- user-repository.go
- module.go
- post-service.go
- post-controller.go
- post-repository.go
- module.go
- comment-service.go
- comment-controller.go
- comment-repository.go
- go.mod
- go.sum
- app-module.go
- main.go
main.go in the cmd folder. The modules can stay in the root or moved to internal/ folder depending on the preference.
- main.go
- app-module.go
- module.go
- user-service.go
- user-controller.go
- user-repository.go
- module.go
- post-service.go
- post-controller.go
- post-repository.go
- module.go
- comment-service.go
- comment-controller.go
- comment-repository.go
- go.mod
- go.sum
By Types
- module.go
- user-controller.go
- post-controller.go
- comment-controller.go
- module.go
- user-service.go
- post-service.go
- comment-service.go
- module.go
- user-repository.go
- post-repository.go
- comment-repository.go
- go.mod
- go.sum
- app-module.go
- main.go
main.go in the cmd folder. The modules can stay in the root or moved to internal/ folder depending on the preference.
- main.go
- app-module.go
- module.go
- user-controller.go
- post-controller.go
- comment-controller.go
- module.go
- user-service.go
- post-service.go
- comment-service.go
- module.go
- user-repository.go
- post-repository.go
- comment-repository.go
- go.mod
- go.sum