File I/O Tutorial - Read, Write, Scanner & Append | Go Tutorial #22

13views
00
11:31
T
Taught by Celeste AI - AI Coding Coach
View on YouTube
Description
Learn how to work with files in Go! In this tutorial, we cover reading files, writing files, line-by-line processing with Scanner, and appending data to existing files. 📚 What You'll Learn: • Reading files with os.Open and io.ReadAll • Getting file info with os.Stat • Writing files with os.Create and WriteString • Line-by-line reading with bufio.Scanner • Word-by-word parsing with ScanWords • Appending to files with os.OpenFile flags • Proper error handling and defer for cleanup ⏱️ Timestamps: 0:00 - Introduction 0:24 - Reading Files (os.Open, io.ReadAll) 2:45 - Writing Files (os.Create, WriteString) 5:10 - Line-by-Line with bufio.Scanner 7:50 - Appending to Files (os.OpenFile) 10:30 - Recap & Key Takeaways 💻 Source Code: https://github.com/GoCelesteAI/go_file_io 🔗 Key Functions Covered: • os.Open() - Open file for reading • os.Create() - Create new file for writing • os.OpenFile() - Open with custom flags • io.ReadAll() - Read entire file contents • bufio.NewScanner() - Create line scanner • os.Stat() - Get file information 📖 Go Documentation: • os package: https://pkg.go.dev/os • bufio package: https://pkg.go.dev/bufio • io package: https://pkg.go.dev/io ▶️ Previous: Lesson 21 - Packages & Modules ▶️ Next: Lesson 23 - Working with JSON #golang #go #programming #tutorial #fileio #coding #learntocode

Tags

golanggo programminggo tutorialfile ioread file gowrite file gobufio scanneros.Openos.Creatego file handlinggolang tutorial for beginnerslearn golanggo programming tutorialfile operations goappend file go
Back to tutorials

Duration

11:31

Published

February 3, 2026

Added to Codegiz

March 15, 2026

Open in YouTube