14. Working with Files
Working with files is a very common task in computer programming. You work with log files, HTML files, and a whole host of other file types in your programs. In this chapter, we explain how to read and write files, walk directories, use the fs
1 package, and finally, embed files into your Go binaries to create a truly self-contained application.
Directory Entries and File Information
Before you can begin using files for your programs, you first need to understand the basics of how files work in Go.
Consider the file tree in Listing 14.1. We use this file tree to help you understand files in Go. This tree contains .txt
files as well as special directories testdata
, _ignore
, and .hidden
. We cover ...
Get Go Fundamentals: Gopher Guides 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.