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
+25.8k PHP : Count number of JSON items/objects
+6.2k Golang : Calculate how many weeks left to go in a given year
+7.2k Golang : Metaprogramming example of wrapping a function
+25.4k Golang : How to check if a connection to database is still alive ?
+25.9k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+16.8k Golang : Find IP address from string
+8.9k CodeIgniter : Load different view for mobile devices
+23k Golang : Time slice or date sort and reverse sort example
+6.8k Golang : Get all countries phone codes
+5.9k Linux : How to fix Brother HL-1110 printing blank page problem
+6.9k Golang : Handle Palindrome string with case sensitivity and unicode
+5.5k Golang : How to determine if request or crawl is from Google robots