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
+20.4k PHP : Convert(cast) int to double/float
+7.3k Gogland : Single File versus Go Application Run Configurations
+9.8k Golang : Channels and buffered channels examples
+16.1k Golang : Check if a string contains multiple sub-strings in []string?
+37.4k Golang : Comparing date or timestamp
+8.8k Golang : Simple histogram example
+7k Golang : Of hash table and hash map
+5.7k Golang : Shuffle array of list
+11k Golang : How to pipe input data to executing child process?
+29.5k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+14.3k Golang : Missing Bazaar command
+8.2k PHP : How to parse ElasticSearch JSON ?