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
+4.9k Golang : Calculate a pip value and distance to target profit example
+7.8k Golang : Regular Expression find string example
+15.8k Golang : Get digits from integer before and after given position example
+8.7k Golang : Gorilla web tool kit schema example
+18.3k Golang : How to remove certain lines from a file
+23.4k Golang : Check if element exist in map
+11.9k Golang : Clean formatting/indenting or pretty print JSON result
+11.3k Golang : Characters limiter example
+14.3k Golang : On enumeration
+9k Golang : How to use Gorilla webtoolkit context package properly
+12.9k Swift : Convert (cast) Int to String ?
+6.8k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?