Go provides file-opening flags represented by constants defined in the os
package. These flags determine the behavior of file operations, such as opening, creating, and truncating files. The following is a list of the flags and what they do.
-
os.O_RDONLY
: Opens the file as read-only. The file must exist. -
os.O_WRONLY
: Opens the file as write-only. If the file exists, its contents are truncated. If it doesn't exist, a new file is created. -
os.O_RDWR
: Opens the file for reading and writing. If the file exists, its contents are truncated. If it doesn't exist, a new file is created.