Book Image

Go Standard Library Cookbook

By : Radomír Sohlich
Book Image

Go Standard Library Cookbook

By: Radomír Sohlich

Overview of this book

Google's Golang will be the next talk of the town, with amazing features and a powerful library. This book will gear you up for using golang by taking you through recipes that will teach you how to leverage the standard library to implement a particular solution. This will enable Go developers to take advantage of using a rock-solid standard library instead of third-party frameworks. The book begins by exploring the functionalities available for interaction between the environment and the operating system. We will explore common string operations, date/time manipulations, and numerical problems. We'll then move on to working with the database, accessing the filesystem, and performing I/O operations. From a networking perspective, we will touch on client and server-side solutions. The basics of concurrency are also covered, before we wrap up with a few tips and tricks. By the end of the book, you will have a good overview of the features of the Golang standard library and what you can achieve with them. Ultimately, you will be proficient in implementing solutions with powerful standard libraries.
Table of Contents (13 chapters)

To get the most out of this book

Although the Go programming platform is cross-platform, the recipes in the book usually assumes a Unix-based operating system, or at least that some common Unix utilities are available for execution. For Windows users, the Cygwin or GitBash utilities could be useful. The sample code works best with this setup:

  • Unix-based environment
  • A version of Go equal to or greater than 1.9.2
  • An internet connection
  • Read, write, and execute permissions on a folder where the sample code will be created and executed

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Go-Standard-Library-Cookbook. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Verify that your GOPATH and GOROOT environmental variables are set properly."

A block of code is set as follows:

package main
import (
"log"
"runtime"
)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

package main
import (
"log"
"runtime"
)

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this.

Warnings or important notes appear like this.
Tips and tricks appear like this.