File Operations in Go

From NovaOrdis Knowledge Base
Revision as of 21:06, 29 February 2024 by Ovidiu (talk | contribs) (→‎Internal)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

The os package provides practical file access functions.

Basic file read and write, by reading or writing the entire file into and from memory, is also provided by the ioutil package, but its ioutil.ReadFile and ioutil.WriteFile are deprecated since Go 1.16.

The bufio package can be used to read a text file line by line.

File paths and names should be manipulated with the functions exposed by the path and filepath packages, explained here:

File Paths and Names in Go