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
+5.2k Golang : Get S3 or CloudFront object or file information
+8.7k Golang : Populate or initialize struct with values example
+15k Golang : How to add color to string?
+12k Golang : How to display image file or expose CSS, JS files from localhost?
+7.3k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image
+8.5k Golang : Executing and evaluating nested loop in html template
+12k Golang : List running EC2 instances and descriptions
+11k Golang : Intercept and process UNIX signals example
+8.6k Golang : Heap sort example
+7.2k Golang : Process json data with Jason package
+9k Golang : Create and shuffle deck of cards example
+12.8k Golang : Calculate elapsed years or months since a date