December 2021
Intermediate to advanced
510 pages
11h 20m
English
Before deleting files that are consuming too much space, you might want to back them up in a compressed form so you can keep them around in case you need them later. Let’s add an archiving feature to the walk tool to enable this feature.
To add this new feature, you’ll use the standard library package compress/gzip to compress data using the gzip format, and io, which provides functions to help with Input/Output operations such as copying data. The package io is already included in the import list. Add the compress/gzip package to the import list in the file actions.go:
| | import ( |
| » | "compress/gzip" |
| | |
| | "fmt" |
| | "io" |
| | "log" |
| | "os" |
| | "path/filepath" |
| | ) |
Define the new action function archiveFile(destDir, ...
Read now
Unlock full access