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
+4.9k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?
+17k Golang : Iterating Elements Over A List
+22.9k Golang : Daemonizing a simple web server process example
+7.8k Golang : Get final balance from bit coin address example
+31.5k Golang : Smarter Error Handling with strings.Contains()
+2.9k Java : Random alphabets, alpha-numeric or numbers only string generator
+8.7k Golang : How to check if a website is served via HTTPS
+22.7k Golang : Generate MD5 checksum of a file
+8k Golang : Find the length of big.Int variable example
+8.7k Golang : Turn string or text file into slice example
+16.3k Golang : How to remove certain lines from a file
+3.1k Golang : PGX CopyFrom to insert rows into Postgres database