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 : zlib compress file example
+10.2k Golang : Wait and sync.WaitGroup example
+21.6k Golang : Setting up/configure AWS credentials with official aws-sdk-go
+7.4k Golang : Detect sample rate, channels or latency with PortAudio
+6.6k Golang : Derive cryptographic key from passwords with Argon2
+13.7k Golang : Get dimension(width and height) of image file
+18.7k Golang : Delete duplicate items from a slice/array
+9.8k Golang : Translate language with language package example
+13.4k Golang : Strings comparison
+19.8k Golang : How to run your code only once with sync.Once object