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
+12k Golang : How to parse plain email text and process email header?
+16k Golang : Get digits from integer before and after given position example
+14.3k Javascript : Prompt confirmation before exit
+6.3k PHP : Get client IP address
+22.3k Golang : How to run Golang application such as web server in the background or as daemon?
+9.3k Golang : How to find out similarity between two strings with Jaro-Winkler Distance?
+14.2k Golang : Reverse IP address for reverse DNS lookup example
+8.2k Golang : Variadic function arguments sanity check example
+7k Golang : Pat multiplexer routing example
+11.8k Golang : Gorilla web tool kit secure cookie example
+15.4k Golang : Accurate and reliable decimal calculations
+8k Javascript : How to check a browser's Do Not Track status?