DEV Community

Sagnick Dey
Sagnick Dey

Posted on

Building My First Server in Go

Coming from a background of full-stack developer , I've always wanted to explore new languages and their applicational varieties. Go caught my attention quickly as one of most popular languages nowadays. So I decided why not take a look.

**

The First Introduction

**
Go is a statically-typed, compiled language , which has much similarity with C and C++ . So it was not that hard for me to grasp the basic ideas.
I learned about slices , maps , structs, interfaces , error handling and many more.

**

Creating the Server

**
After becoming a bit familiar with Go , with one or two small-scale projects, I decided to jump into the backend development in Go.

**

Folder structure in Go

**
Backend--
|--cmd <-- The main file 'main.go' goes here
|--config/config.go
|internal
|--local.yaml
This is a very basic folder structure i used in this project. I used some in-built and third-party packages for it , like :
--> CleanEnv for config mapping
--> net/http -- The standard go package to create server, better for learning the internal workings of the server and APIs
-->slog -- for logging

Learning a Graceful shutdown of a server using GoRoutines and Channels was also amazing application of go concepts. Here are some images of it.

I think that'll be it for today , i don't want my first post to be very lengthy. Feel free to tell about your experiences of learning Go for the first time .
πŸ‘‹πŸ»Signing off,
Sagnick
Creating a server
graceful shurdown

Top comments (0)