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
+42k Golang : How do I convert int to uint8?
+7.4k Golang : Individual and total number of words counter example
+8.8k Golang : Heap sort example
+10.7k Golang : Allow Cross-Origin Resource Sharing request
+20.5k nginx: [emerg] unknown directive "passenger_enabled"
+43.6k Golang : Get hardware information such as disk, memory and CPU usage
+7.9k Golang : Load DSA public key from file example
+7.3k Golang : How to fix html/template : "somefile" is undefined error?
+26.4k Golang : Convert(cast) string to uint8 type and back to string
+9.3k Golang : Create and shuffle deck of cards example
+12.7k Golang : Transform comma separated string to slice example
+15.1k Golang : Search folders for file recursively with wildcard support