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
+6.2k Golang : Check a web page existence with HEAD request example
+24.6k Get client IP Address in Go
+3.9k Golang : Handling image beyond OpenCV video capture boundary
+3.4k Golang : Issue HTTP commands to server and port example
+4.8k Golang : Handling Yes No Quit query input
+5.6k Golang : Generate random Chinese, Japanese, Korean and other runes
+1.8k Java : Random alphabets, alpha-numeric or numbers only string generator
+4.6k Golang : Ways to recover memory during run time.
+7.4k Golang : ROT47 (Caesar cipher by 47 characters) example
+3.9k Javascript : Get operating system and browser information
+10.9k Golang : concatenate(combine) strings
+12.9k Golang : Gzip file example