Skip to content

Philipelima/go-books-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Books API

Go Postgres Docker Swagger


A Simple Monolithic Golang API built with Gorilla/Mux and PostgreSQL, to enhance my Golang Knowledge, documented with swagger.

Download this project:
 git clone https://github.com/Philipelima/go-books-api.git

Execute go mod tidy to download the required dependencies:

 go mod tidy

To run the PostgreSQL DB, please run the following command:

 docker compose up

Migrations

The database migrations are handled using the migrate package. You can learn more about it on Golang Migrate.

You’ll find all migration files in cmd/migrate/migrations. After configuring the migrate package on your machine, you can run:

   make migrate-up

If you need to roll back the migrations, run:

   make migrate-down

If you want to add a new migration to the project:

   make migration {migration_name}

Seeds

It’s possible to run database seeds in this project. You can find the seed script in cmd/seed.

To use it, simply create a {entity}.json file inside cmd/seed/data, following the payload structure, and then implement the EntitySeed interface in the entity you want to use for populating the database.

After that, just run:

   go run cmd/seed/main.go seed:{json_file_name}

Runing the Project

After all configurations done, just run:

  make dev

To See the swagger docs, access http://127.0.0.1:8000/swagger/index.html#/

About

A Simple Monolithic Golang API built with Gorilla Mux and PostgreSQL.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published