Skip to content

Dima-Melnik/go-restapi-example-with-gin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Go REST API Example with Gin & Gorm

A simple example project showing how to build a REST API in Go using Gin, Gorm, and configuration files (config.yaml and .env).


πŸ“ Project Structure

go-restapi-example-with-gin/
β”œβ”€β”€ config/ # Configuration files 
β”‚ β”œβ”€β”€ config.yaml
β”‚ └── config.go
β”œβ”€β”€ internal/ # Core business logic
β”‚ β”œβ”€β”€ handler/
β”‚ β”œβ”€β”€ routes/
β”‚ β”œβ”€β”€ database/
β”‚ β”œβ”€β”€ utils/
β”‚ └── model/
β”œβ”€β”€ .env
β”œβ”€β”€ main.go # Entry point
β”œβ”€β”€ go.mod
β”œβ”€β”€ go.sum
β”œβ”€β”€ .gitignore
└── README.md

βš™οΈ Example config.yaml

server:
  port: 8080

database:
  db_host: localhost
  db_port: 5432
  db_user: postgres
  db_name: example_db
  db_sslmode: disable

πŸ” Example .env

DB_PASSWORD="your_password"

Application

🧩 Technologies Used Go 1.25.3

Gin β€” HTTP web framework

Gorm β€” ORM for database access

PostgreSQL

YAML / env

πŸš€ Getting Started

1. Clone the repository

git clone https://github.com/Dima-Melnik/go-restapi-example-with-gin.git
cd go-restapi-example-with-gin

3. Install dependencies

go mod tidy

4. Run the application

go run main.go

About

Golang restAPI with gin, gorm, yaml, env

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages