Session Cookie Authentication in Golang (With Complete Examples)

In this post, we will learn how to authenticate users using session cookies in a Golang server application. When a user logs into our application, we need to know who they are across all our HTTP methods and routes. One way to do this is to store the users “session”. A session is started once a user logs in, and expires some time after that. Each logged in user has some reference to the session (called a cookie), which they send with their requests....

Last Updated:   · Written by Soham Kamani

How to Implement Password Authentication and Storage in Go (Golang)

This post will explain how to sign up and login users using password based authentication in Go. Any application that stores passwords has to ensure that its passwords are stored securely. You can’t just store passwords as plain text, and it should ideally be impossible to guess your users passwords, even if you have access to their data. In this post, we will explain the production-ready method for storing passwords, and build a web application in Go to demonstrate it in practice....

Data races in Go(Golang) and how to fix them

Go is known for how easy it is to build concurrent programs in it. But, with all this concurrency, comes the possibility of the dreaded data race – one of the hardest bugs to debug if you’re ever unfortunate enough to encounter it in your code. In this post, we will go through a sample program that causes a data race, and detect the race condition with the race detector tool....

A Complete Guide to JSON in Golang (With Examples)

In this post, we will learn how to work with JSON in Go, in the simplest way possible. We will learn how to convert from JSON raw data (strings or bytes) into Go types like structs, arrays, and slices, as well as unstructured data like maps and empty interfaces. JSON is used as the de-facto standard for data serialization in many applications, ranging from REST APIs to configuration management. By the end of this post, you’ll get familiar with how to marshal (encode) and unmarshal (decode) JSON in Go....

Last Updated:   · Written by Soham Kamani

Build a web application in Go (golang)

Go is getting more and more popular as the go-to language to build web applications. This is in no small part due to its speed and application performance, as well as its portability. There are many resources on the internet to teach you how to build end to end web applications in Go, but for the most part they are either scattered in the form of isolated blog posts, or get into too much detail in the form of books....

Last Updated:   · Written by Soham Kamani

An Introduction to Channels in Go (Golang)

This post highlights how channels work in Go, and how you can use them in your code. In Go, a channel is a programming construct that allows us to move data between different parts of our code, often from different goroutines. Creating Channels We can declare a new channel type by using the chan keyword along with a datatype: var c chan int Here, c is of type chan int - which means it’s a channel through which int types are sent....

Last Updated:   · Written by Soham Kamani