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.9k Golang : Calculate a pip value and distance to target profit example
+7.1k Golang : Auto-generate reply email with text/template package
+9.9k Golang : Create S3 bucket with official aws-sdk-go package
+7k Golang : Qt splash screen with delay example
+7.6k Golang : Sort lines of text example
+5.3k Golang : Extract sub-strings
+12.9k Golang : Convert IP version 6 address to integer or decimal number
+14.6k Golang : Update database with GORM example
+7.1k Golang : Oanda bot with Telegram and RSI example
+11.1k Golang : Forwarding a local port to a remote server example
+13.9k Golang : Find location by IP address and display with Google Map
+7.2k How to show different content from website server when AdBlock is detected?