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
+4k Golang : Print instead of building pyramids
+9.1k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+6.7k Golang : Ways to recover memory during run time.
+3.7k Chrome : How to block socketloop.com links in Google SERP?
+13.5k Golang : Accurate and reliable decimal calculations
+29.7k Golang : Get local IP and MAC address
+14.6k Golang : Update database with GORM example
+5.3k PHP : Proper way to get UTF-8 character or string length
+6k Golang : A simple forex opportunities scanner
+28k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+15k Golang :Trim white spaces from a string
+5k Java : Human readable password generator