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
+10.2k Android Studio : Simple input textbox and intercept key example
+9.9k Golang : How to tokenize source code with text/scanner package?
+22.6k Golang : Gorilla mux routing example
+9.1k Golang : Timeout example
+10.5k Golang : Get currencies exchange rates example
+14.9k Golang : Accurate and reliable decimal calculations
+11.1k Golang : Characters limiter example
+25.4k Golang : How to write CSV data to file
+5.2k Golang : What is StructTag and how to get StructTag's value?
+14.9k JavaScript/JQuery : Detect or intercept enter key pressed example
+9.7k Golang : Function wrapper that takes arguments and return result example