Golang os.Open() and os.OpenFile() functions examples
package os
Golang os.Open() and os.OpenFile() functions usage examples
Example 1:
file, err := os.Open("datafile.dat")
Example 2:
file, err = os.OpenFile(os.DevNull, os.O_WRONLY, 0)
file, err = os.OpenFile("datafile.dat", os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
outFile, err := os.OpenFile("decrypted-file", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
file, err := os.OpenFile("exec_me", os.O_CREATE|os.O_EXCL, 0700)
References :
Advertisement
Something interesting
Tutorials
+14.2k Golang : Convert IP version 6 address to integer or decimal number
+11.2k Google Maps URL parameters configuration
+8k Golang : Sort words with first uppercase letter
+22.2k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+7.8k Golang : Lock executable to a specific machine with unique hash of the machine
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+9.5k Golang : Extract or copy items from map based on value
+10.2k Golang : How to profile or log time spend on execution?
+35.1k Golang : Upload and download file to/from AWS S3
+23.5k Golang : Read a file into an array or slice example
+10.1k Golang : Check a web page existence with HEAD request example
+5.6k Unix/Linux : How to find out the hard disk size?