Logging Deleted Files
Command-line tools can be executed interactively by a user, but they are often used as part of a larger script that coordinates several other tasks to automate a process. In both cases, it’s a good idea to provide constant feedback so the user or script knows that the tool is doing some work and it hasn’t hung unexpectedly.
In general, you use STDOUT to provide feedback to the user onscreen. For scripts or tools that are executed in the background, such as a batch job, it’s useful to provide feedback in log files so the user can verify them later.
Go’s standard library provides the log package to facilitate logging information. By default, it will log information to STDERR, but you can configure it to log to a file instead. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access