![]() A permission value is identical to *NIX systems i.e. OpenFile() also needs another paramter, permission. To open a file with other flags, OpenFile() has to be used. O_TRUNC int = syscall.O_TRUNC // if possible, truncate file when opened. ![]() O_SYNC int = syscall.O_SYNC // open for synchronous I/O. O_EXCL int = syscall.O_EXCL // used with O_CREATE, file must not exist O_CREATE int = syscall.O_CREAT // create a new file if none exists. O_APPEND int = syscall.O_APPEND // append data to the file when writing. O_RDWR int = syscall.O_RDWR // open the file read-write. O_WRONLY int = syscall.O_WRONLY // open the file write-only. O_RDONLY int = syscall.O_RDONLY // open the file read-only. There are several modes declared in the package. The code below shows the pattern.įile, err := os.Open("file1.txt") // O_RDONLY mode The os package allows a Go program to interface with files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |