We break down file I/O in Go as working with resources: why it’s important to close
*
os
.
File via
defer, how to place
defer correctly after checking
err, how
os
.
Open,
os
.
Create, and
os
.
OpenFile differ, and how to use the flags
os
.
O_APPEND,
os
.
O_CREATE,
os
.
O_EXCL. Separately, we discuss the normal
io
.
EOF, common errors, and build a mini example: a “todo in a file”.