Skip to content

haqiqiw/go-api-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-api-example

A sample Go API implementation using clean architecture.

Dependencies

  • MySQL – Primary database
  • Redis – Caching and session store
  • Kafka – Event streaming platform

Frameworks & Libraries

Running with Docker Compose

Start all required services:

docker-compose up -d

Stop all services:

docker-compose down

Make sure all containers are running before running database migration and starting the app.

Kafka UI is available at http://localhost:8080/

Database Migration

Apply migration:

migrate -path ./db/migrations -database "mysql://root:root@tcp(localhost:3306)/api-example" up

Rollback migration:

migrate -path ./db/migrations -database "mysql://root:root@tcp(localhost:3306)/api-example" down

Create new migration file:

migrate create -ext sql -dir db/migrations <migration_name>

Running the Application

Copy .env from env.sample and adjust configuration values:

cp env.sample .env

Run the API server:

go run cmd/api/main.go

Run the Kafka consumer:

go run cmd/consumer/main.go

About

A sample Go API implementation using Fiber.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published