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
+9.5k Golang : How to generate Code 39 barcode?
+8.9k Golang : Go as a script or running go with shebang/hashbang style
+28.4k Golang : Read, Write(Create) and Delete Cookie example
+6.8k Golang : Pat multiplexer routing example
+46k Golang : Read tab delimited file with encoding/csv package
+41.4k Golang : Convert string to array/slice
+9k Golang : How to use Gorilla webtoolkit context package properly
+7.2k Golang : How to iterate a slice without using for loop?
+6.7k Golang : Find the longest line of text example
+10.8k Golang : How to transmit update file to client by HTTP request example
+4.7k Fix Google Analytics Redundant Hostnames problem
+8.2k Golang : Oanda bot with Telegram and RSI example