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
+11k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+12.9k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+10.2k Swift : Convert (cast) String to Integer
+10.7k Golang : Replace a parameter's value inside a configuration file example
+7.2k Golang : Dealing with struct's private part
+6.7k Golang : Find the shortest line of text example
+20.9k Golang : How to get time zone and load different time zone?
+6.9k Golang : Use modern ciphers only in secure connection
+27k Golang : dial tcp: too many colons in address
+13.7k Golang : Get current time
+10k Golang : Convert file content to Hex
+24.1k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?