Golang : Create File
Any sane programming language should have the basic File I/O functions. Luckily Go is one programming language in the sane category. We will show you how to create basic file in Go and more advance stuffs in the next couple of tutorials.
Ok, let's begin. Below is the code in Go for creating a file
package main
import (
"fmt"
"os"
)
func main () {
w, err := os.Create("output.txt")
if err != nil {
panic(err)
}
defer w.Close()
fmt.Printf("File created!)
}
References :
See also : Golang : Create Temporary File
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+8.3k Facebook : Getting the friends list with PHP return JSON format
+11.2k Elastic Search : Return all records (higher than default 10)
+20.9k Golang : Repeat a character by multiple of x factor
+8k Golang : How to check if a string with spaces in between is numeric?
+7.7k Golang : Capture text return from exec function example
+4k Linux/Unix/MacOSX : Find out which application is listening to port 80 or use which IP version
+7.6k Golang : Gonum standard normal random numbers example
+10.6k Golang : Gorilla web tool kit secure cookie example
+8.1k Golang : Read file with ioutil
+4.3k Golang : Detect words using using consecutive letters in a given string
+4.2k Gogland : Datasource explorer