Golang Fiber REST API with GORM and PostgreSQL

This is a simple REST API written in Golang using the Fiber framework, GORM and PostgreSQL.

Tools

  1. Golang 1.21.1
  2. Fiber v2.49.2

Prerequisites

  1. Install Golang
  2. Install PostgreSQL
  3. Install Fiber
  4. Install GORM
  5. Install GORM PostgreSQL Driver

Setup

  1. Clone this repository
  2. Create a database in PostgreSQL
  3. Copy .env.example to .env and change some values
  4. Run go get to install all dependencies
  5. Run go run main.go to start the server
  6. Open your browser and go to http://localhost:3000/api/note to see the list of notes

API Endpoints

Method Endpoint Description
GET /api/note Get all notes
GET /api/note/:id Get a single note
POST /api/note Create a new note
PUT /api/note/:id Update a note
DELETE /api/note/:id Delete a note

Example Create a new note

```json
{
"title": "Test",
"subtitle": "Testsss",
"text": "Test Juga"
}
```

Swagger Documentation

  1. Open your browser and go to http://localhost:3000/docs to see the swagger documentation

References

  1. Golang
  2. Fiber
  3. GORM
  4. GORM PostgreSQL Driver
  5. PostgreSQL
  6. Tutorial
  7. Swagger