REST API Application Initial Setup

Learn how to set up the REST API with local storage.

Introduction

This application is created with the Go programming language and some additional libraries. The libraries that are used in this project are:

  • fiber for creating a server with its handler.
  • uuid for creating an ID for data or records inside the storage.
  • validator for request validation.

Initialize the project

Initialize the project with this command if you have to run it on a local machine. However, it has already been set up for you at the Educative platform.

go mod init domain_name/username/project_name

Here’s an example of initializing the project command.

go mod init github.com/nadirbasalamah/go-simple-inventory

After the project is initialized, install some libraries using the following commands. Again, they have already been set up for you at the Educative platform.

The following command is used to install fiber for creating a server.

go get -u github.com/gofiber/fiber/v2

The following command is used to install uuid for creating an ID for data or records inside the storage.

go get github.com/google/uuid

The following command is used to install validator for request validation.

go get github.com/go-playground/validator/v10

Create the server

The file called main.go is created to create the server using the Fiber library.

Get hands-on with 1400+ tech skills courses.