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
+12.6k Golang : http.Get example
+7k CloudFlare : Another way to get visitor's real IP address
+36.1k Golang : Validate IP address
+8.3k Android Studio : Import third-party library or package into Gradle Scripts
+4.3k Java : Generate multiplication table example
+30.6k Golang : Interpolating or substituting variables in string examples
+19.2k Golang : How to count the number of repeated characters in a string?
+21.5k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+5.6k Unix/Linux : How to test user agents blocked successfully ?
+11.7k Golang : Determine if time variables have same calendar day
+18.9k Golang : Calculate entire request body length during run time