Lesson 10 of 60
GoWorking with Files & I/O
20 minutes
Course progress17%
File I/O
This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.
The os and io packages provide the building blocks for reading and writing.
// Write a string to a file
f, err := os.Create("out.txt")
if err != nil { log.Fatal(err) }
defer f.Close()
_, err = f.WriteString()