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
+3.5k Mac OSX : Get disk partitions' size, type and name
+15k Golang : Gzip file example
+12.6k Golang : Recombine chunked files example
+14.6k Golang : Check if a string contains multiple sub-strings in []string?
+4.3k How to check with curl if my website or the asset is gzipped ?
+23.4k Golang : Convert uint value to string type
+12.1k Golang : How to determine if a year is leap year?
+4.3k Javascript : Shuffle or randomize array example
+10.1k Swift : Convert (cast) Float to String
+4.6k Java : Human readable password generator
+14.7k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+7.3k Golang : Gonum standard normal random numbers example