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
+6.9k Golang : Muxing with Martini example
+14.1k Golang : concatenate(combine) strings
+7.7k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image
+10.1k Golang : Convert octal value to string to deal with leading zero problem
+9.5k Golang : How to get username from email address
+6.1k Fontello : How to load and use fonts?
+25.2k Golang : Create PDF file from HTML file
+34.1k Golang : Proper way to set function argument default value
+12.5k Elastic Search : Return all records (higher than default 10)
+8.5k Golang : Implementing class(object-oriented programming style)
+15.7k Golang : Force download file example