Posts for: #Go

Golang Web: URL Parsing

Introduction

We have done around 32 posts on the fundamental concepts in golang, With that basic foundation, I’d like to start with the new section of this series which will be a major one as web-development. This section will have nearly 40-50 posts, this will cover the fundamental concepts for web development like APIs, Database integrations, Authentication and Authorizations, Web applications, static sites, etc.

What is a URL?

A URL is a Uniform Resource Locator. It is a string of characters that identifies a resource on the Internet. URLs are the building blocks of the web, allowing us to access websites, documents, and data with just a click. URLs are all over the place, if we want to build a strong foundation in web development, it’s quite important to understand what URLs actually mean and what can they store.

[]

Golang: Channels

Introduction

In this part of the series, we will be continuing with the concurrency features of golang with channels. In the last post, we covered the fundamentals of go routines and wait groups. By leveraging those understood concepts, we will explore channels to communicate the data between various go routines.

What are Channels

A golang Channel is like a pipe that lets goroutines communicate. It lets you pass values from one goroutine to another. Channels are typed i.e. you declare them with chan keyword followed by the type to be sent and received (e.g. chan int). The chan type specifies the type of values that will be passed through the channel. We will explore the detailed technicalities soon. Right now, we need to just focus on what problem is channels solving.

[]

Golang: Go Routines and WaitGroups

Introduction

One of the key features that set Go apart from many other languages is its native support for Goroutines - lightweight concurrent functions that can run concurrently and efficiently manage concurrency tasks. Goroutines are an essential aspect of Go’s concurrency model, enabling developers to build highly concurrent and performant applications effortlessly.

In this blog post, we will dive into the world of Goroutines and explore how they work, why they are essential for concurrent programming in Go, and how they can greatly improve the responsiveness and efficiency of your applications. This post will cover go routines and a primer on wait groups, in the next article we will be looking deeply into channels where all these three things can be demonstrated and understood in a better and more useful way.

[]

Golang: Generics

Introduction

In the 29th post of the series, we will be looking into generics in Golang. Generics were added in Golang version 1.18, so they are quite new in the world of Golang but the concept is quite old in other programming languages.

Generics provide a powerful toolset for writing more expressive and concise code that can handle a wide range of data types. With generics, we can write reusable algorithms, data structures, and functions that work seamlessly with various types, without sacrificing type safety.

[]

Golang: Date and Time

Introduction

In the 28th post of the series, I will be exploring date and time handling in Golang. We will be covering the following topics:

  • Date and Time parsing

  • Time Duration

  • Time and Date Arithmetic

  • Timezones

  • Sleep and Tickers

This will cover most of the methods and properties used extensively in general use cases related to time and date operations.

Time package

The Golang standard library provides the time package to handle date and time-related operations. It has a lot of methods and constants to work and handle data related to time and dates.

[]

Golang: Random Numbers

Introduction

In the 27th post of the series, we will be looking into random number generation in golang. We will be exploring how to create a random number, generate random numbers within a range, shuffle slices/arrays, and generate random strings, float, and bytes.

There are two types of random number generation processes in software pseudo-random numbers and cryptographically secure pseudo-random number generation.

The math/rand package in Golang provides a number of functions for generating pseudorandom numbers. These functions are suitable for a variety of applications, such as games, simulations, and to some extent in cryptography.

[]

Golang: Regex

Introduction

In this 26th part of the series, we will be covering the basics of using regular expressions in golang. This article will cover the basic operations like matching, finding, replacing, and sub-matches in a regular expression pattern from string source or file content. This will have examples for each of the concepts and similar variants will follow the same ideology in self-exploring the syntax.

Regex in golang

So, let’s start with what are regular expressions.

[]

Golang: Command Line Arguments

Introduction

In the 25th post of the series, we will be taking a look into parsing of command line arguments in golang. We will be exploring how to do the basics of parsing and using the positional parameters or arguments from the command line in the program. By using standard library packages like os and flag, we can make powerful yet easy-to-build CLI apps and programs.

Parsing Arguments from the command line (os package)

We can use the os package to get the arguments from the command line in a go script. We have to use the Args variable in the os package. The Args variable is a slice of strings which thereby is the parsed arguments from the command line.

[]

Golang: File Write

Introduction

In the 24th post of the series, we will be taking a look at how we can perform write operations to a file using golang. We will be using the os package in most operations along with bufio text manipulations. We will be performing write operations like appending, deleting, and replacing a file using golang. We will be heavily leveraging standard library packages like os, bufio, bytes and fmt. We will also be looking into overwriting and string formatting to a file.

[]