filmov
tv
Working with Files in Golang - Simple Command Line Tool

Показать описание
This tutorial shows how files can be accessed in Golang. We create a simple command line tool for adding, removing and listing items that are stored in a file. You will learn about different approaches including their pros and cons. Moreover, we will discuss why error handling and resource cleanup are important.
Links:
Timestamps:
00:00:00 Content overview
00:04:22 Project setup
00:06:49 Using command line arguments
00:10:45 Exiting the program (return code, error handling)
00:15:14 Switch case
00:19:15 Constants
00:23:43 Opening files for reading
00:31:12 Handling errors
00:33:00 Reading bytes from a file ourself
00:42:08 Reading all bytes from a file simply
00:44:42 Closing files (resource cleanup and defer)
00:51:18 Buffered reading using Scanner
00:57:25 Multiple constants short form
01:00:12 Extracting multiple command line arguments (slicing)
01:03:06 Extracting error handling (reducing code repetition)
01:05:04 Writing to a new file
01:05:56 Trimming whitespaces from strings
01:11:41 Writing to the end of a file with seek
01:16:54 Writing to the end of a file with append mode
01:18:16 Buffered writing (flush method)
01:23:02 Combining read and write for modifying file content (truncate)
01:42:25 Creating an executable file (go build)
01:44:14 Short summary
Links:
Timestamps:
00:00:00 Content overview
00:04:22 Project setup
00:06:49 Using command line arguments
00:10:45 Exiting the program (return code, error handling)
00:15:14 Switch case
00:19:15 Constants
00:23:43 Opening files for reading
00:31:12 Handling errors
00:33:00 Reading bytes from a file ourself
00:42:08 Reading all bytes from a file simply
00:44:42 Closing files (resource cleanup and defer)
00:51:18 Buffered reading using Scanner
00:57:25 Multiple constants short form
01:00:12 Extracting multiple command line arguments (slicing)
01:03:06 Extracting error handling (reducing code repetition)
01:05:04 Writing to a new file
01:05:56 Trimming whitespaces from strings
01:11:41 Writing to the end of a file with seek
01:16:54 Writing to the end of a file with append mode
01:18:16 Buffered writing (flush method)
01:23:02 Combining read and write for modifying file content (truncate)
01:42:25 Creating an executable file (go build)
01:44:14 Short summary