DEV Community

Cover image for Fiber web framework written in Go πŸŽ‰
Siddhesh Khandagale
Siddhesh Khandagale

Posted on

Fiber web framework written in Go πŸŽ‰

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 πŸ™‚

Getting Started πŸ’»:

Image description

Let's start the implementation using Fiber. First of all, you need to install 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
Enter fullscreen mode Exit fullscreen mode

Instead Siddheshk02 use the directory name inside which all the project repos are.

Now, for installing fiber run the following command πŸš€:

go get
Enter fullscreen mode Exit fullscreen mode

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 (

func main() {

    app := fiber.New()

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


Enter fullscreen mode Exit fullscreen mode

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

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

When you follow the given link i.e. the message will be displayed πŸ™‚

Image description

You can find the complete repository for this tutorial here πŸ‘‰ Github

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 and GitHub.

Until then Keep Learning, Keep Building πŸš€πŸš€

Top comments (0)