Standard Library

Explore Go’s standard library in this lesson.

Standard library

A library is a collection of functionalities that can be invoked through interfaces. The latter is used to abstract the underlying implementation details, which can be written in any language. The usage of libraries assists with better code reusability as we need to write that particular feature only once and then it can be shared with other projects.

In Go

Like most programming languages, Go also has a standard library. It contains all of the basic functionalities, which we can use out of the box. Usually, the standard library provides us with the tools to write a simple program that can:

  • Manipulate basic data
  • Interact with the underlying operating system
  • Do some basic logging
  • Manage errors

In the next sections, we’ll focus on some of these functions.

Archive

To accomplish archive operations we can take advantage of two packages: tar, which implements access to tar archives, and zip, which supports reading and writing to ZIP archives.
In the following example, we’re going to create an archive with the zip package.

Get hands-on with 1200+ tech skills courses.