DEV Community


Posted on • Updated on

Getting started with Fiber

New gophers that make the switch from Node.js to Go are dealing with a learning curve before they can start building their web applications or microservices. Fiber, as a web framework, was created with the idea of minimalism and follows the UNIX way, so that new gophers can quickly enter the world of Go with a warm and trusted welcome.

Fiber is inspired by Express, the most popular web framework on the Internet. We combined the ease of Express and raw performance of Go. If you have ever implemented a web application in Node.js (using Express or similar), then many methods and principles will seem very common to you.

We listen to our users in issues, Discord channel and all over the Internet to create a fast, flexible and friendly Go web framework for any task, deadline and developer skillset! Just like Express does in the JavaScript world.

Step 1: Install Go

You can get the latest version of Go from the official Golang website follow the instructions and you're good to go, make sure you install Go 1.14 or higher.

To confirm you have Go installed open your terminal or command prompt and run the following command:

> go version
go version go1.15 windows/amd64
Enter fullscreen mode Exit fullscreen mode

You should get the version number of your Go installation.

Step 2: Creating your first project

In your project directory, we want to create a go.mod to manage our dependencies. Type the following:

> go mod init demo
go: creating new go.mod: module demo
Enter fullscreen mode Exit fullscreen mode

Now create a file called main.go in the project directory write the following code in it:

package main

import (


func main() {
    app := fiber.New()

    app.Get("/", func(c *fiber.Ctx) error {
        return c.SendString("Hello, World 馃憢!")

Enter fullscreen mode Exit fullscreen mode

The above code is actually the bare-bones to get the server respond with a Hello, World 馃憢!

Save the file and run the following command to update your go.mod

> go mod tidy
go: finding module for package
go: found in v2.0.5
Enter fullscreen mode Exit fullscreen mode

This will create a go.sum file that ensures that future downloads of these modules retrieve the same bits as the first download, to ensure the modules your project depends on do not change unexpectedly, whether for malicious, accidental, or other reasons

Your project folder should contain the following file structure:

   鈹溾攢鈹 main.go
   鈹溾攢鈹 go.mod
   鈹斺攢鈹 go.sum
Enter fullscreen mode Exit fullscreen mode

Let's launch our app by calling the following command:

go run main.go
Enter fullscreen mode Exit fullscreen mode

Visit http://localhost:3000 in your browser. You will see the following:

At this point, you have successfully set up your first Fiber application.

Step 3: Explore Fiber

Fiber has a great community and online documentation that can help you creating fast and secure web apps.

See ya 馃憢

Top comments (8)

hamptonjt profile image
Jerry Hampton

Greetings! I've been wanting to try Go for a while and this looks awesome coming from a Node background. I really want to see this take off. Do you have any examples of this working with SSO (SAML, in particular?) because we utilize Shibboleth where I work. I'd love to transition some of our APIs to use this instead of Express. Great work on this!

hamptonjt profile image
Jerry Hampton

Just wanted to give an update on saml... I鈥檝e got a working proof of concept that I can take to the office... this framework really rocks and I just wanted to thank you for all your work.

youngaltair profile image
Young Altair

I face the same challenge as you. Can you share some knowledge, how do you implement SAML on your Service Provider?
we're currently still using JWT Auth and now all the existing applications (service providers) will implement SAML (SSO).
Thanks in advance

koddr profile image
Vic Sh贸stak

Awesome article! Thanks :)

kiyonlin profile image

Great introduction to fiber! So easy to start a web server with tons of features out of box.

fhek789 profile image
Felipe Kinoshita

really nice intro to fiber! You should made more fiber tutorials/guides especially since you created it l!

aceix profile image

Thanks. Was looking for pointers as I am new to Go

s1ntaxe770r profile image

You're doing really good work fenny, the fiber community is very welcoming