How to split a slice into uniform chunks in Go
Splitting a slice into chunks of uniform sizes is pretty straightforward in most programming languages, and its no different in Go.
Splitting a slice into chunks of uniform sizes is pretty straightforward in most programming languages, and its no different in Go.
How do you build Go binaries that target operating systems and architectures other than your own? This is called cross-compiling, and it’s …
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 …
Unlike other languages, Go does not provide a built-in function for removing an element from a slice
The difference between nil and empty slices are a common point of confusion for newbies to Go. This post discusses how they differ and when …
This article examines some of the ways you can fetch a list of all the files in a directory using stdlib methods in Go.
In this article, we'll go over some ways to distinguish between files and directories in Go
This article explores five different ways to concatenate strings in Go, and explains the pros and cons of each one.
This article explores a few techniques in Go that should make the sorting of any data collections a breeze.
The builtin copy() and append() functions eases the task of duplicating slices in Go, but you'll need to watch out for some edge cases
Learn a few strategies for checking if a map contains a specific key in Go.
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 …
Support for extracting a part of a string is built into Go, but there's one important aspect to consider.
The canonical way to perform this operation is by using strings.Contains, but we'll consider some other options as well.
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 builtin append() function eases the task of joining multiple slices in Go, but you need to watch out for certain side effects
Creating a multiline string is quite straightforward in Go. This article will show you how it's done
This article describes all the ways to print struct values in Go for debugging purposes
This article describes different ways to access the type of a variable in Go
This article deals with the common operation of converting a string to an integer in Go
Converting a number to a string is easy in most programming languages, and its no different in Go
Learn how to count the spaces before first character of 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
This article describes how you can parse the response of a web request and access it as a string in Go.
Iterating over individual string characters is quite straightforward in Go
This article provides a solution for padding numbers with leading zeros in Go
In most programs, you'll need to iterate over a collection to perform some work. This article will teach you how slice iteration is …
Learn how to count the number of times a character occurs in a string using the Go standard library
Learn how to access URL query parameters in a request URL using the Go standard library
Learn the easy way to convert a string to a byte slice in Go and vice versa
This article provides two main approaches to determining if a file or directory exists in Go
Learn how to execute a specific test instead of the whole test suite in Go
Learn how to get a filename without its extension in the Go programming language
This snippet describes how to prevent template execution errors from causing a broken page to be rendered to users.
This post will describe how to retrieve the base64 representation of any image using the Go standard library
This article describes the process for specifically checking for HTTP timeout errors on a Go web server
The Go standard library provides support for detecting the content or MIME types of files through its net/http package
Find out why this TypeScript error occurs and how to fix it by making TypeScript understand the correct type for EventTarget
Go provides the `strings.TrimSpace()` method for removing whitespace characters from a string
In this article, you'll learn how to make multipart related requests in Go using standard library packages
This snippet describes how to avoid weird results when performing integer division in Go
Converting a slice of strings to a single string is pretty easy to do in Go through the strings.Join() method
The Go standard library provides the strings.Split() method for the purpose of converting a single string to a slice of strings
This short article will help you solve the problem of selectively or recursively creating a directory if it does not exist in Go
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. …
Extracting the last path segment of a URL in Go can be done through the `path.Base()` method in the standard library
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
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
This article covers several ways to perform regular expression replacements in Go including replacing from the end of the text and replacing …
Searching for how to reset a file pointer in Go? Look no further than this article.
The time package provides a `Now()` method for retrieving the current date and time in the language
It is often necessary to add or subtract a specific duration (such as hours, minutes or seconds) to a time value. Read this article to find …
Converting an integer to a Roman numeral can be achieved in Go with just a few lines of code
Learn how to reset a for loop in Go so that it starts iterating over the collection from the beginning once again
This article will teach you how to test for the presence of optional shortcode parameters in Hugo
Systemd provides some options that will help you configure if a service should be restarted in the event of a failure. Read on to find out …
This article details a few approaches for checking if a struct is empty in Go. It accounts for structs with comparable and non-comparable …
Do you need to discover if there is an alias for a specific cmdlet in Windows PowerShell? Read on to find out how it's done.
The http package in Go allows you to create an HTTP server to receive HTTP requests and redirect the client to a different URL
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.
Jumping to a tag under the cursor in the Vim documentation window (:help) is done through the `Ctrl-]` keybinding
Printing the memory address of a variable is sometimes useful for debugging. Here's all the ways to retrieve this value in Go
Learn three ways to compare two slices in Go, whether they are equal, have the same length, or contain the same elements.