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
+7.5k Golang Hello World Example
+10.7k Google Maps URL parameters configuration
+14k Golang : Reset buffer example
+13k Golang : Verify token from Google Authenticator App
+19.7k Golang : How to get struct tag and use field name to retrieve data?
+7.5k Golang : Handle Palindrome string with case sensitivity and unicode
+9.4k PHP : Get coordinates latitude/longitude from string
+6.3k Golang : Find the longest line of text example
+7k Golang : Scanf function weird error in Windows
+6.4k Golang : Muxing with Martini example
+10.1k Android Studio : Checkbox for user to select options example
+16.8k Golang : Check if IP address is version 4 or 6