From the course: Learning the Go Standard Library

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Temporary files and directories

Temporary files and directories - Go Tutorial

From the course: Learning the Go Standard Library

Start my 1-month free trial

Temporary files and directories

- [Instructor] All right, let's close out this chapter by seeing how to work with temporary files and directories, which, under certain circumstances, you'll probably need to work with. So, these are files and directories that you'll use just to hold information for a short period of time. So, for example, you might be downloading content from the network from several different sources, and you'll want to consolidate it into a single file, or, you know, you might want to download content to a temporary location before moving it to a more secure final directory. So, in this example, we'll see how to use the Go packages that are relevant to these features. So, here in the Start folder for chapter four, let's go into Tempfiles and open up temps_start. Let's start by seeing how to get the path to the system's temporary directory, and you can do this with the TempDir function from the OS package. So, let me go ahead and import the…

Contents