Fiber web framework written in Go 🎉
Tags: go, gofiber, framework, series
Published: 2023-01-02 14:09:09

## Introduction :
Hey there 👋, today we are going to start with a very young and exciting Fiber Web Framework that is written in Golang. It is a great tool for creating Rapid Web Applications.

## Useful Information 💯:
Fiber is an Express.js styled HTTP web framework implementation running on Fasthttp, the fastest HTTP engine for Go (Golang). The package makes use of a similar framework convention as they are in Express.

It was created with the idea of minimalism to more easily start creating a web application's backend for experienced as well as new gophers.

For more detailed information you just need [official documentation](https://docs.gofiber.io/) 🙂

## Getting Started 💻:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/li5wmypr6vtighys12pw.png)

Let's start the implementation using Fiber. First of all, you need to install [Fiber](https://github.com/gofiber/fiber).

## Initializing :
Before that make a repository for eg. `go-fiber-series` , Now initialize a mod file. _(If you publish a module, this must be a path from which your module can be downloaded by Go tools. That would be your code's repository.)_

```
go mod init github.com/Siddheshk02
```
Instead `Siddheshk02` use the directory name inside which all the project repos are.

Now, for installing fiber run the following command 🚀:

```
go get github.com/gofiber/fiber/v2
```
Make a new file main.go in the same folder. Now we'll just try a simple program using Fiber Framework 🚀

Write the following code in the `main.go` file _(It is better to write/Type instead of just copy-pasting)_🙂

```
package main

import (
    "github.com/gofiber/fiber/v2"
)

func main() {

    app := fiber.New()

    app.Get("/", func(c *fiber.Ctx) error {
        return c.SendString("Hello World!!, This is Go-Fiber Tutorial Series")
    })

    app.Listen(":8080")

}
```
Now, let's understand what this code means :)

`app` is an instance of Fiber, fiber.New() creates a new instance.

`app.Method(path string, ...func(*fiber.Ctx) error)` This is how the route is defined in fiber.

`Method` is an HTTP Request Method : `GET`, `PUT`, `POST`, etc.

`path` is a virtual path on the server.

`func(*fiber.Ctx)` error is a callback function containing the context executed when the route is matched.

`return c.SendString(" ")` send the message with the Request.

Here the message is : `"Hello World!!, This is Go-Fiber Tutorial Series"`

`app.Listen()` starts the server at the given port.

Now, run the main.go file. For that run the command `go run main.go` .

#### Output ✨🚀:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xw1q4u3m4egoctsy1kg.png)

After running the main.go the output will look like the above-given image.

When you follow the given link i.e. `http://127.0.0.1:8080` the message will be displayed 🙂

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wpr8qe3n83u22gc3im72.png)

You can find the complete repository for this tutorial here 👉 [Github](https://github.com/Siddheshk02/go-fiber-series)

## Conclusion 💯:
I hope you must have got a basic understanding of the fiber web framework and how to get started with it through this tutorial.

In the next upcoming tutorial, you will learn some advanced topics and concepts of the young Fiber Web Framework along with building some crazy stuff 🎉

To get more information about Golang concepts, projects, etc. and to stay updated on the Tutorials do follow [Siddhesh on Twitter](https://twitter.com/siddhesh1102) and [GitHub](https://github.com/Siddheshk02).

Until then **Keep Learning, Keep Building** 🚀🚀