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.8k Linux/MacOSX : How to symlink a file?
+3.7k Java : Get FX sentiment from website example
+14.7k Golang : Execute function at intervals or after some delay
+11.7k Golang : Fuzzy string search or approximate string matching example
+14.2k Golang : Check if a file exist or not
+9.6k Golang : Get all countries currencies code in JSON format
+11.9k Golang : Verify Linux user password again before executing a program example
+11.8k Golang : Concurrency and goroutine example
+21.2k Golang : For loop continue,break and range
+9.2k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+10k Golang : ffmpeg with os/exec.Command() returns non-zero status
+5.3k JavaScript/JQuery : Redirect page examples