How to Compare Slice Equality in Go
Learn three ways to compare two slices in Go, whether they are equal, have the same length, or contain the same elements.
Learn three ways to compare two slices in Go, whether they are equal, have the same length, or contain the same elements.
Printing the memory address of a variable is sometimes useful for debugging. Here's all the ways to retrieve this value in Go
If you're looking for a way to verify if a string is valid JSON in Go regardless of its schema, the `encoding/json` package has you covered.
The http package in Go allows you to handle URL redirection through its Redirect() method
This article details a few approaches for checking if a struct is empty in Go, accounting for structs with comparable and non-comparable …
Learn how to use MongoDB as a data store for a Go application through the official Mongodb Go driver
This article will teach you how to test for the presence of optional shortcode parameters in Hugo
Learn how to reset a for loop in Go so that it starts iterating over the collection from the beginning once again
This article demonstrates a comprehensive linting setup for Go projects, and discusses the best way to introduce it into an existing …
Converting an integer to a Roman numeral can be achieved in Go with just a few lines of code
Read this article to learn how to add or subtract time (hours, minutes, seconds) from a timestamp in Go.
The time package provides a `Now()` method for retrieving the current date and time in the language
Searching for how to reset a file pointer in Go? Look no further than this article.
This article covers several ways to perform regular expression replacements in Go including replacing from the end of the text and replacing …
Obtaining the current user's home directory on Windows, macOS and Linux is easy to do in Go with just a few lines of code
Creating a hidden file or directory is easy to do in Go, but there are differences in how it's done on Linux/macOS compared to Windows
Extracting the last path segment of a URL in Go can be done through the `path.Base()` method in the standard library
For Unix-based operating systems such as Linux or macOS, all you need to do is check if the first character of the file is a dot character. …
This short article will help you solve the problem of selectively or recursively creating a directory if it does not exist in Go
The Go standard library provides the strings.Split() method for converting a single string to a slice of strings
Converting a slice of strings to a single string is easy to do in Go through the strings.Join() method
This snippet describes how to avoid weird results when performing integer division in Go
In this article, you'll learn how to make multipart related requests in Go using standard library packages
Go provides the `strings.TrimSpace()` method for removing whitespace characters from a string
The Go standard library provides support for detecting the content or MIME types of files through its net/http package
This article describes the process for specifically checking for HTTP timeout errors on a Go web server
This post will describe how to retrieve the base64 representation of any image using the Go standard library
This snippet describes how to prevent template execution errors from causing a broken page to be rendered to users.
This article will teach you how you can upload single or multiple files to a Golang web server, and show progress reporting on file uploads
Learn how to get a filename without its extension in the Go programming language
Learn how to execute a specific test instead of the whole test suite in Go
This article provides two main approaches to determining if a file or directory exists in Go
Learn the easy way to convert a string to a byte slice in Go and vice versa
Learn how to access URL query parameters in a request URL using the Go standard library
Learn how to count the number of times a character occurs in a string using the Go standard library
In most programs, you'll need to iterate over a collection to perform some work. This article will teach you how slice iteration is …
This article provides a solution for padding numbers with leading zeros in Go
Iterating over individual string characters is quite straightforward in Go
This article explains how to parse a web request response and access it as a string in Go.
This article describes how to iterate over each line of a multiline string (such as the content of text files) in Go
Learn how to count the spaces before first character of a string in Go
Converting a number to a string is easy in most programming languages, and its no different in Go
This article deals with the common operation of converting a string to an integer in Go
This article explores various methods to determine a variable's type in Go.
This article describes all the ways to print struct values in Go for debugging purposes
Creating a multiline string is quite straightforward in Go. This article will show you how it's done
Starting from Go 1.22, concatenating slices is straightforward with the introduction of the `slice.Concat()` method
Checking if a slice or array contains an item in Go is really easy as long as you're using Go 1.18 or later.
The canonical way to perform this operation is by using strings.Contains, but we'll consider some other options as well.
Support for extracting a part of a string is built into Go, but there's one important aspect to consider.
This article will take you through the various basic data types in Go, the operations that can be done on these types, and how to convert …
You can iterate over maps in Go but, unlike slices, the order of iteration is not guaranteed. There are ways to get around this, and that is …
Learn some strategies for checking if a map contains a specific key in Go.
The built-in copy() and append() functions help you duplicate slices in Go, but you'll need to watch out for some edge cases
This article explores a few techniques in Go that should make the sorting of any data collections a breeze.
This article explores five different ways to concatenate strings in Go, and explains the pros and cons of each one.
In this article, we'll go over some ways to distinguish between files and directories in Go
In this article, we'll cover some variable basics and best practices for using them within Go programs.
This article examines some of the ways you can fetch a list of all the files in a directory using stdlib methods in Go.
This article clarifies the often confusing difference between nil and empty slices in Go, offering guidance on their appropriate use.
Unlike other languages, Go does not provide a built-in function for removing an element from a slice
There are multiple ways to read user input from the terminal console in Go. Let's consider three basic scenarios you are likely to encounter …
This tutorial introduces you to a few common Golang concepts by showing you how to use them to implement a classic beginner programming …
Cross-compiling in Go allows you to build binaries for different operating systems and architectures than your own
Go is currently one of the fastest growing programming languages in the software industry. Its speed, simplicity, and reliability make it …
Splitting a slice into chunks of uniform sizes is pretty straightforward in most programming languages, and its no different in Go.
This tutorial will teach you how to build a real world web app with Go and how to deploy it to production
The tutorial provides an exercise in Golang by describing how to build a simple countdown timer