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
+5.7k Unix/Linux : How to find out the hard disk size?
+13.8k Android Studio : Password input and reveal password example
+14.5k Golang : How to shuffle elements in array or slice?
+19.6k Golang : Example for DSA(Digital Signature Algorithm) package functions
+5.2k Linux : How to set root password in Linux Mint
+18.8k Golang : Find IP address from string
+10.7k Golang : ISO8601 Duration Parser example
+9.6k Golang : Apply Histogram Equalization to color images
+10k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+7.2k Golang : Gargish-English language translator
+18.1k Golang : Login and logout a user after password verification and redirect example
+6.1k Linux/MacOSX : Search for files by filename and extension with find command