Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Snippet: OpenFile with more options. Last param is the permission mode
- // Second param is the attributes when opening
- // Use these attributes individually or combined
- // with an OR for second arg of OpenFile()
- // e.g. os.O_CREATE|os.O_APPEND
- // or os.O_CREATE|os.O_TRUNC|os.O_WRONLY
- // os.O_RDONLY // Read only
- // os.O_WRONLY // Write only
- // os.O_RDWR // Read and write
- // os.O_APPEND // Append to end of file
- // os.O_CREATE // Create is none exist
- // os.O_TRUNC // Truncate file when opening
- file, err := os.OpenFile("test.txt", os.O_APPEND, 0666)
- if err != nil {
- log.Fatal(err)
- }
- defer func() { _ = file.Close() }()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement