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
+18.7k nginx: [emerg] unknown directive "passenger_enabled"
+6.9k Swift : Convert (cast) String to Float
+6.3k Golang : Example of how to detect which type of script a word belongs to
+18k Golang : Convert seconds to human readable time format example
+7.7k Golang : Find duplicate files with filepath.Walk
+3.9k Golang : Customize scanner.Scanner to treat dash as part of identifier
+6.2k Golang : Dealing with struct's private part
+35.5k Upload multiple files with Go
+4.1k Python : Create Whois client or function example
+5.9k Golang : Null and nil value
+5.5k Nginx : Password protect a directory/folder
+7.1k Golang : HTTP Server Example