Skip to content

Go lang API framework structure and cli with gin and gorm

License

Notifications You must be signed in to change notification settings

usama-tariq1/leet-gin

Repository files navigation

Golang Api Framework

This template should help get you started developing with Golang

Current Project is Based on Gorm and Gin-Gonic

Project Setup (With out CLI)

Clone project and run

go get

Project Setup (With CLI)

Install Cli

go install "github.com/usama-tariq1/leet-astro@latest"

Test Cli

leet-astro

Create project

leet-astro init ProjectName "ModUser"

example

leet-astro init Test "github.com/usama-tariq1"

assuming go 1.18 or greater is already installed on system

Install Dependencies

go get

Database Config .env

copy .env.example and make .env file fill in Database configs

Compile with

This will also create migrations in database if tables are not already created

With Cli

leet-astro serve

With Out Cli

go run main.go

note that project does not support hot reload

Cli Create Commands

Create Controller

With Resource and methods already built

leet-astro create controller ControllerName --model=ModelName

With out methods

leet-astro create controller ControllerName

Create Model

create just model with query methods

leet-astro create model ModalName

With controller auto generated

leet-astro create model Name --controller=true

With controller and router auto generated

leet-astro create model Name --controller=true --router=true

Create Router

leet-astro create router NameRouter

Create Middleware

leet-astro create middleware Name

Router functions , http and response handling Docs

Gin-Gonic Docs.

Database and ORM Docs

GORM Docs.