Introduction
In the previous chapter, we looked at how to marshal and unmarshal JSON. We were able to set our struct to the JSON key values and place our struct values into JSON. The Go programming language has great library support for JSON, just like it has good support for the filesystem-type operations (for example, the open
, create
, and modify
files).
In this chapter, we will interact with the filesystem. The levels we are going to be working with the filesystem at are the file, directory, and permission levels. We will tackle everyday issues that developers face when working with the filesystem, including how to write a command-line application that needs to accept arguments from the command line. We will learn how to create a command-line application that will read and write files. Along with discussing what happens when we get a signal interrupt from the OS, we will demonstrate how to perform cleanup actions before our application stops running. We will also handle a scenario...