Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

File System Operations with | Go Programming Bootcamp lesson | BraveProgrammer
  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 34 of 60

·Go

File System Operations with `os` and `io/ioutil`

15 minutes

Course progress57%

FS Helpers

This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.

Create, read, write, and delete files.

// Write a file
err := os.WriteFile("out.txt", []byte("hello"), 0644)

// Read a file
data, err := os.ReadFile()


f, _ := os.OpenFile(, os.O_APPEND|os.O_WRONLY, )
 f.Close()
f.WriteString()
"out.txt"
// Append to a file
"out.txt"
0644
defer
" more"

Directory traversal

dir, _ := os.ReadDir(".")
for _, entry := range dir {
    fmt.Println(entry.Name(), entry.IsDir())
}

Temporary files

tmp, _ := os.CreateTemp("", "prefix-*.tmp")
defer os.Remove(tmp.Name())

Info

When using ioutil (deprecated) switch to the newer os and io functions introduced in Go 1.16.
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from Go Programming BootcampBrowse activities
Previous lessonWorking with Environment VariablesContinue to lesson 35Time Package – Parsing, Formatting, and TimersBack to Go Programming Bootcamp curriculum