Compression

The Go standard library also supports compression, which is different than archiving. Often, archiving and compressing are combined to package a large number of files in to a single compact file. The most common format is probably the .tar.gz file, which is a gzipped tar ball. Do not confuse zip and gzip as they are two different things.

The Go standard library has support for multiple compression algorithms:

  • bzip2: bzip2 format
  • flate: DEFLATE (RFC 1951)
  • gzip: gzip format (RFC 1952)
  • lzw: Lempel-Ziv-Welch format from A Technique for High-Performance Data Compression, Computer, 17(6) (June 1984), pp 8-19
  • zlib: zlib format (RFC 1950)

Read more about each package at https://golang.org/pkg/compress/. These examples use gzip compression, ...

Get Security with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.